Outlook doesn't recognise ical attachment

2019-08-27 16:26发布

问题:

I have to send calendar invites from a classic ASP application to be received into Outlook. Using various different email components (ASPEmail, ASPMail, JMail) I have sent mails with attachments but when they are received, Outlook doesn't recognise the attachment as a calendar invite, whereas GMail does.

In JMail I can set the content-type of the attachment to text/calendar but this makes no difference.

The invite has been tested here and it validates fine.

I am open to any solutions to this problem, including working the invite as inline, but unfortunately .NET and PHP are not options.

Here is some test code - JMail was the only component i could find where I could set the attachment content-type.

set msg = Server.CreateOBject( "JMail.Message" )
set attachment = Server.CreateOBject( "JMail.Attachment" )

msg.Logging = true
msg.silent = true

msg.From = "website@userdomain.com"
msg.FromName = "Website"
msg.AddRecipient "outlook@userdomain.com", "Outlook"
msg.Subject = "Meeting"
msg.Body = "Meeting invite attached"

'although cid not needed, i could only get this to work by using cid =
cid = msg.AddAttachment (server.mappath(".\invite.ics"), false, "text/calendar")

msg.ContentType = "text/calendar"

if not msg.Send("mail.userdomain.com" ) then
    Response.write "<pre>" & msg.log & "</pre>"
else
    Response.write "Message sent succesfully!"
end if

After setting the message content-type as text/calendar as well, when clicking on the attachment it's now displaying as hex rather than a simple text file. It's still not recognised as an invite. Here is the top of it:

This is a multipart message in MIME format.
----NEXT_BM_D29EC5CD87384387A59E240A29CD74DD
Content-Type: text/plain;
    charset="iso-8859-1"
Content-Transfer-Encoding: Quoted-Printable

Meeting invite attached

----NEXT_BM_D29EC5CD87384387A59E240A29CD74DD
Content-Type: text/calendar; name="=?iso-8859-1?Q?invite=2Eics?="
Content-Transfer-Encoding: base64
Content-Description: =?iso-8859-1?Q?invite=2Eics?=
Content-Disposition: attachment; filename="=?iso-8859-1?Q?invite=2Eics?="
Content-ID: <8AB4D71598B445B88353F487644AC2F3>

I'm using a test version of Office Professional Plus 2013 by the way.

A similar message received at GMail shows these headers:

Content-Type: text/calendar;
    boundary="--NEXT_BM_675B64750B5649EAAF1A3F3D9EC69302"
Return-path: <website@userdomain.com>

This is a multipart message in MIME format.
----NEXT_BM_675B64750B5649EAAF1A3F3D9EC69302
Content-Type: text/plain;
    charset="iso-8859-1"
Content-Transfer-Encoding: Quoted-Printable

Meeting invite attached

----NEXT_BM_675B64750B5649EAAF1A3F3D9EC69302
Content-Type: text/calendar; name="=?iso-8859-1?Q?invite=2Eics?="
Content-Transfer-Encoding: base64
Content-Description: =?iso-8859-1?Q?invite=2Eics?=
Content-Disposition: attachment; filename="=?iso-8859-1?Q?invite=2Eics?="
Content-ID: <C6C87170FE7B4BC581E7EE33EE24BC71>

So the message type is indeed set to text/calendar but the text part of the message is set to text-plain.

Using a modified version of the code, with the body set to the actual iCal data, and with a content-type of text/calendar, Outlook still doesn't recognise it as an invite but converts the body to an attachment using the message subject as the filename eg test.ics

回答1:

Due to pressure from the client to find a solution quickly, I have elected to use the old vCalendar version 1 specs and to do this using a .vcs file rather than a .ics.

In testing Outlook has proven happy to recognise a text .vcs attachment as a calendar entry, without the need for special content-types etc. This format, although quite old, has all the functionality that our client needs.

Full specs for vCalendar version 1.0 (.vcs) can be found at http://www.imc.org/pdi/pdiproddev.html



回答2:

Make sure the message content type is calendar, not just the attachment. If the invitation needs to include attachments, they need to be embedded into the iCal part, not added as separate attachments.