3

I am trying to send an ICS (calendar) file to someone that read it using Office365, using C#. Sending just the ICS works fine. But I have to attach a file. At this point, the mail is received without calendar, or the calendar is attached to the email and cannot be used, or the attachment is missing. I tried 2 different ways:
1. send attachment inside VEVENT, using ATTACH;ENCODING=BASE64;VALUE=BINARY;X-FILENAME=file.txt:, but this does not show any attachment in Office365 (like here: Attaching a file to an iCalendar)
2. send attachment as a separate file, and attach it to VEVENT using ATTACH:CID:, but this time the calendar file is displayed as attachment

The second way should work if I can format the mail message to look like this:

multipart/mixed
  multipart/alternative
    text/plain
    text/calendar;method=REQUEST
  text/calendar (with a content-disposition:attachment)

(as described in Multipart email with text and calendar: Outlook doesn't recognize ics)
If I send a calendar invite using Outlook365, the message looks like that.(but instead of the calendar as attachment, the image or doc is attached)

but using System.Net.Mail.MailMessage, I can generate a message like this

multipart/mixed
  multipart/alternative
    text/plain
    text/calendar;method=REQUEST
  multipart/mixed
    text/plain (with a content-disposition:attachment)

Desktop version of Outlook 2007 shows both calendar and attachment, so it seems that Outlook365 is very strict about the format.

But how can I send, using .NET classes, an email that does not have the extra multipart/mixed section? MailMessage class generate for the Attachments collection a new section with content type multipart/mixed, insead of adding them to the top level.

Community
  • 1
  • 1

0 Answers0