I would like to be able to send a multipart/alternative e-mail (particularly a text/calendar encoded item so that outlook, gmail, etc. open up their menus for interacting with the attached appointment (allowing the user to add it to their own personal calendar). The e-mail server is a different box, obviously I’m sending via anonymous SMTP. The following are the headers and message being passed into php 5.3.6 mail() method:
From: TestNet
Reply-To: TestNet
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="--Meeting Booking--fec0d81281514f7f839dc4cf0c117f64"
Content-class: urn:content-classes:calendarmessage
--Meeting Booking--fec0d81281514f7f839dc4cf0c117f64
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
Dear Robert Burnham,
Here is my HTML Email / Used for Meeting Description
--Meeting Booking--fec0d81281514f7f839dc4cf0c117f64
Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8
Content-Transfer-Encoding: 8bit
BEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:test@test.net
DTSTART:20121206T134000Z
DTEND:20121206T144000Z
LOCATION:My Office
TRANSP:OPAQUE
SEQUENCE:0
UID:20121116T092255-9178@mydomain.com
DTSTAMP:20121116T152255Z
DESCRIPTION:Here is a brief description of my meeting
SUMMARY:Meeting Booking
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
The e-mail sends successfully, however I find that the $message I passed in was treated just as raw HTML (the following appears in the actual body of the e-mail):
--Meeting Booking--b37b5edb86b3e7047ce15b2b348159d7
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<html>
<body>
<p>Dear Robert Burnham,</p><p>Here is my HTML Email / Used for Meeting Description</p>
</body>
</html>
--Meeting Booking--b37b5edb86b3e7047ce15b2b348159d7
Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8\nContent-Transfer-Encoding: 8bit\n\nBEGIN:VCALENDAR
PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
ORGANIZER:MAILTO:mailer@personalhealthsurvey.net
DTSTART:20121206T134000Z
DTEND:20121206T144000Z
LOCATION:My Office
TRANSP:OPAQUE
SEQUENCE:0
UID:20121116T092814-12916@mydomain.com
DTSTAMP:20121116T152814Z
DESCRIPTION:Here is a brief description of my meeting
SUMMARY:Meeting Booking
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
END:VCALENDAR
As a final followup, I got this to work on my own, but having oberron’s link: Here would have made it a lot easier. That being said, I ended up undoing all of my work and intentionally “breaking” the iCalendar attachment so that it wouldn’t be recognized by outlook. As if Outlook’s HTML parsing wasn’t bad enough (since it uses the same HTML parser that’s built into Microsoft Word), when a “valid” iCalendar meeting attachment is recognized, the parser drops into an incredibly rudimentary mode which I couldn’t work around. HTML parsing, in particular, went to shit..and this is apparently the intended functionality (when you are creating an e-mail in outlook and attach an event, all html-editing related buttons/functionality disappear for that message.
In the end, tolerable HTML formatting was worth the user having to click on the iCalendar attachment themselves.