Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

c# - Why are my icalendar invitations not processed by the outlook sniffer?

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;[email protected]:mailto:[email protected]
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=
 FALSE;[email protected];X-NUM-GUESTS=0:mailto:[email protected]
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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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">
<html>
<body>
<table border="1"><tr><td>
<b>HTML</b> Description o
 f flying to Sligo
</td></tr><tr><td>
<ul><li>HTML has certain advantages
 </li></ul>
</td></tr></table>
</body>
</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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...