Reputation: 13194
I am failing to construct a MIME message that is displayed as a meeting invitation in Outlook, compared to when sending an invitation natively via Outlook.
What I want is this view (at least more or less):
What I get instead:
(The file displayed as .ics attachment can be opened and shows correct content).
Here's the meeting body (ics), that I construc programmatically:
BEGIN:VCALENDAR
VERSION:2.0
PRODID:123
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Europe/Amsterdam
BEGIN:STANDARD
TZOFFSETTO:+0100
TZOFFSETFROM:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Europe/Amsterdam:20201214T085500
DTEND;TZID=Europe/Amsterdam:20201214T095500
SUMMARY:Test Event
LOCATION:skico HQ
DESCRIPTION:A test in appointment chatbot
PRIORITY:3
END:VEVENT
END:VCALENDAR
The MIME message is built via MimeKit:
private static string BuildMimeContent(Mail mail)
{
var textBody = new TextPart("plain") { Text = mail.BodyText };
var htmlBody = new TextPart("html") { Text = mail.BodyHtml };
var alternative = new Multipart("alternative");
alternative.Add(textBody);
alternative.Add(htmlBody);
var multiPart = new Multipart("mixed") { alternative };
if (mail.Event != null)
{
var eventBody = mail.Event.Parse();
var calendarBody = new TextPart("calendar")
{
Text = eventBody,
ContentTransferEncoding = ContentEncoding.Base64
};
calendarBody.ContentType.Parameters.Add("method", "REQUEST");
calendarBody.ContentType.Parameters.Add("name", "meeting.ics");
alternative.Add(calendarBody);
}
var mimeMessage = new MimeMessage();
mimeMessage.From.Add(new MailboxAddress(mail.Sender.Name, mail.Sender.EMail));
mimeMessage.To.Add(new MailboxAddress(mail.Recipient.Name, mail.Recipient.EMail));
mimeMessage.Subject = mail.Subject;
mimeMessage.Body = multiPart;
// parse and return mime message
return mimeMessage.ToString();
}
yielding:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-rdfmBTE1TuDNFI0Wzfmibg=="
--=-rdfmBTE1TuDNFI0Wzfmibg==
Content-Type: multipart/alternative; boundary="=-6bp3YWbl6STSnwQq7Fne2A=="
--=-6bp3YWbl6STSnwQq7Fne2A==
Content-Type: text/plain; charset=utf-8
Hi!
--=-6bp3YWbl6STSnwQq7Fne2A==
Content-Type: text/html; charset=utf-8
<strong>Hi!</strong>
--=-6bp3YWbl6STSnwQq7Fne2A==
Content-Type: text/calendar; charset=utf-8; method=REQUEST
Content-Id: <[email protected]>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 15.0 MIMEDIR//EN
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Europe/Amsterdam
BEGIN:STANDARD
TZOFFSETTO:+0100
TZOFFSETFROM:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=Europe/Amsterdam:20201214T120800
DTEND;TZID=Europe/Amsterdam:20201214T130800
SUMMARY:Test Event
LOCATION:skico HQ
DESCRIPTION:A test in appointment chatbot
PRIORITY:3
END:VEVENT
END:VCALENDAR
--=-6bp3YWbl6STSnwQq7Fne2A==--
--=-rdfmBTE1TuDNFI0Wzfmibg==--
How does the MIME content need to be constructed instead, such that the alternate view works in Outlook?
Upvotes: 1
Views: 1570
Reputation: 13194
There was something wrong with my ICS content. This fixed it:
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 15.0 MIMEDIR//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20201214T121600Z
DTEND:20201214T131600Z
SEQUENCE:0
UID:56b39b14ebb641ab7de716a62bed46aa
DTSTAMP:20201210T121600Z
LAST-MODIFIED:20201210T121600Z
SUMMARY:Test Event
LOCATION:s HQ
DESCRIPTION:A test in appointment chatbot
END:VEVENT
END:VCALENDAR
I did not track it down to the root cause. Probably the UID is madatory or the date/timezone format was invalid before.
Upvotes: 1