0

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
Cryptic
  • 406
  • 1
  • 4
  • 13
  • 1
    Don't use mail() for compound/mime emails. It's too painful/ugly/buggy. Use a proper mail package, like Swiftmailer or PHPMailer. they make it easy and much more foolproof. mail() is about as useful for real work as a piece of wet toilet paper is in drying out new york. – Marc B Nov 16 '12 at 15:39
  • First, don't use PHP's build-in `mail()` function -- it's not worth the effort, especially if you're doing anything even remotely unusual. Use a class like [phpMailer](http://code.google.com/a/apache-extras.org/p/phpmailer/), and save yourself a lot of hassle. – SDC Nov 16 '12 at 15:39
  • Once you've switched to phpMailer, it's very easy to add an attachment to an email. Then you can simply generate the iCal code block, add it as an attachment, and problem solved. – SDC Nov 16 '12 at 15:41
  • @SDC, I've messed with phpMailer already and attempted precisely what you describe...the attachment is successful, however it does not trigger the "special menu" that Outlook, gmail, etc. show for interacting with appointments: http://postimage.org/image/wwfyjgzoj/ – Cryptic Nov 16 '12 at 15:49
  • have you looked at: http://stackoverflow.com/questions/461889/sending-outlook-meeting-requests-without-outlook – Auberon Vacher Nov 25 '12 at 09:32

1 Answers1

0

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.

Community
  • 1
  • 1
Cryptic
  • 406
  • 1
  • 4
  • 13