-->

Why are my icalendar invitations not processed by

2019-01-15 16:50发布

问题:

Invitations generated by my ASP.net application, sent as email with .ics attachment to Outlook 2010, are not being processed by the sniffer. As such, they are not appearing as tentative in the calendar, and are not available in the preview pane. The .ics attachment appears to be valid and can be opened in outlook by double clicking. The same invitations sent to Gmail are processed no worries. I have ruled out a number of accepted solutions to the same problem...

  • Outlook is correctly configured, and processes Gmail invitations no problem
  • The message is sent as Content-Type: multipart/mixed, with the attachment as text/calendar.
  • DTEND follows DTSTART !
  • The invitation includes an organizer and an attendee.

The most obvious difference between my invitations and Gmails' is the absence of a DKIM signature, but others have succeeded without this. More generally, has anyone found any microsoft documentation about the operation, logging or troubleshooting of the sniffer?

This is my .ics attachment.

BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20140617T083644Z
DTEND:20140617T093644Z
DTSTAMP:20140617T083647Z
ORGANIZER;CN=sby@dimo-gestion.fr:mailto:sby@dimo-gestion.fr
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
 FALSE;CN=bbsimonbb@gmail.com;X-NUM-GUESTS=0:mailto:bbsimonbb@gmail.com
CREATED:20140617T083647Z
DESCRIPTION:Description of flying to Sligo
LAST-MODIFIED:20140617T083647Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Fly to Sligo
TRANSP:OPAQUE
UID:20140617T083647Z
END:VEVENT
END:VCALENDAR

The property X-MS-OLK-FORCEINSPECTOROPEN, specified here, hasn't helped.

My file passes the three iCalendar validators mentionned in this question

My god the internet is clogging up with folk who can't get their invitations into Outlook. Here, here, and here.

The consensus seems to be that you need to add "; method=REQUEST" after the content type in the header of the calendar MIME part. Trouble is, the .net System.Net.Mail library doesn't seem to offer low level access to set this line. The hunt continues.

回答1:

Ok I've cracked it. The solution that's worked for me is the combination of the two suggestions here. The text/calendar part must be the only part of the message, and method=REQUEST must be present in the Content-Type header.

To achieve this in .net, you can use AlternateViews as follows...

MailMessage msg = new MailMessage();
msg.From = new MailAddress("gonzo@work");
msg.To.Add("gonzo@home");

System.Net.Mime.ContentType mimeType = new System.Net.Mime.ContentType("text/calendar; method=REQUEST");
AlternateView icalView = AlternateView.CreateAlternateViewFromString(icalendarString, mimeType);
icalView.TransferEncoding = TransferEncoding.SevenBit;
msg.AlternateViews.Add(icalView);
client.Send(msg);

The nice bit is that, in the absence of a body, attachments or other alternate views, .net is clever enough to construct a mail with just one part. Using an alternateView remains necessary, because it's the only way to control the Content-type header. This trick could be useful for anyone else who wants to set the Content-Type of a simple single-part mail in .net. The resulting mail, then, looks like this...

MIME-Version: 1.0
From: gonzo@work
To: gonzo@home
Subject: Fly to Sligo
Content-Type: text/calendar; method=REQUEST
Content-Transfer-Encoding: 7bit

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//www.notilus.com//Dimo Gestion Notilus//FR
CALSCALE:GREGORIAN
METHOD:REQUEST
X-MS-OLK-FORCEINSPECTOROPEN:TRUE
BEGIN:VEVENT
DTSTART:20140619T080132Z
DTEND:20140619T090132Z
DTSTAMP:20140619T080132Z
ORGANIZER;CN=gonzo@work:mailto:gonzo@work
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
 FALSE;CN=gonzo@home;X-NUM-GUESTS=0:mailto:gonzo@home
CREATED:20140619T080132Z
DESCRIPTION:Description of flying to Sligo
X-ALT-DESC;FMTTYPE=text/html:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//E
 N">\n<html>\n<body>\n<table border="1"><tr><td>\n<b>HTML</b> Description o
 f flying to Sligo\n</td></tr><tr><td>\n<ul><li>HTML has certain advantages
 </li></ul>\n</td></tr></table>\n</body>\n</html>
LAST-MODIFIED:20140619T080132Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Fly to Sligo
TRANSP:OPAQUE
UID:20140619T080132Z
END:VEVENT
END:VCALENDAR

A big thank you to gmail, for effortlessly constructing a working example, and for the marvelous "show original" option. As discussed above, google somehow manages to have a much more complicated message processed correctly, but you need to be a google programmer to figure that out.



回答2:

This quite likely has to do with your message MIME structure. You may have to put the icalendar stream in a multipart/alternative (see http://tools.ietf.org/html/rfc6047#section-4.2 ), or worse, a multipart/mixed containing a multipart/alternative to accomodate all clients.