I've been working on a simple HTML form that will ask the user for info and when submitted, will have a PHP script email certain people with a calendar invite.
I also want the body of this calendar invite to have an HTML body - with an HTML table included.
With the code below I am able to send the email using PHP's mail function and it generates the appointment. I can also add HTML content however the table gets stripped away.
I've read somewhere that the calendar invite only supports RTF. This may be true however I've noticed on an OWA account the table does not get stripped away.
Can someone shed some light on my dilemma? Thanks!
function sendIcalEmail($htmlmsg,$email,$meeting_date,$s_ccemail) {$from_name = "sender name" $from_address = "sender email" $subject = "Test Appointment"; //Doubles as email subject and meeting subject in calendar $meeting_description = "Description" //Convert MYSQL datetime and construct iCal start, end and issue dates $meetingstamp = strtotime($meeting_date . " EST"); $dtstart= gmdate("Ymd\THis\Z",$meetingstamp); $dtend= gmdate("Ymd\THis\Z",$meetingstamp+7200); $todaystamp = gmdate("Ymd\THis\Z"); //Create unique identifier $cal_uid = date("Ymd")."T".date("His")."-".rand()."@mydomain.com"; //Create Mime Boundry $mime_boundary = "----Meeting Booking----".md5(time()); //Create Email Headers $headers = "From: Sender Name <[email protected]>" . "\n"; $headers .= "Cc: ". $s_ccemail . "\n"; $headers .= "Reply-To: [email protected]" . "\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n"; $headers .= "Content-class: urn:content-classes:calendarmessage\n"; //Create Email Body (HTML) $message = ""; $message .= "--$mime_boundary\n"; $message .= "Content-Type: text/html; charset=UTF-8\n"; $message .= "Content-Transfer-Encoding: 7bit\n\n"; $message .= $htmlmsg . "\r\n"; $message .= "--{$mime_boundary}\n";
$ical = " BEGIN:VCALENDAR PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN VERSION:2.0 METHOD:PUBLISH BEGIN:VEVENT ORGANIZER:MAILTO:".$from_address." DTSTART:".$dtstart." DTEND:".$dtend." LOCATION: TRANSP:OPAQUE SEQUENCE:0 UID:".$cal_uid." DTSTAMP:".$todaystamp." DESCRIPTION:".$meeting_description." SUMMARY:".$subject." PRIORITY:5 CLASS:PUBLIC END:VEVENT END:VCALENDAR";$message .= "Content-Type: text/calendar;name="meeting.ics";method=REQUEST;charset=utf-8\n"; $message .= "Content-Type: text/calendar;name="meeting.ics";method=REQUEST\n"; $message .= "Content-Transfer-Encoding: 8bit\n\n"; $message .= $ical; //SEND MAIL $mail_sent = @mail( $email, $subject, $message, $headers ); if($mail_sent) { return true; } else { return false; }}