0
我一直在研究一個簡單的HTML表單,它會詢問用戶的信息,當提交時,將會有PHP腳本通過電子郵件發送給某些具有日曆邀請的人。使用html表發送Outlook ical消息
我也希望這個日曆邀請的正文有一個HTML主體 - 包含HTML表格。
通過下面的代碼,我可以使用PHP的郵件功能發送電子郵件,並生成約會。我也可以添加HTML內容,但表被刪除。
我讀過日曆邀請只支持RTF的地方。這可能是正確的,但是我注意到在OWA賬戶中表格沒有被剝離。
有人可以解釋我的困境嗎?謝謝!
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; }}