PHP中的ICS电子邮件附件

时间:2014-03-18 10:01:07

标签: php icalendar gcal

我需要将.ics事件文件发送到Gmail - 而不是附件,但可以选择将相应的事件作为日历请求添加到日历中。 这样用户就可以将事件添加到Google日历中。有人能指出我正确的方向吗?

2 个答案:

答案 0 :(得分:0)

我使用了以下代码,它只是发送一封电子邮件作为附件,我没有看到接受/添加到谷歌日历选项。

$headers .= "MIME-version: 1.0\r\n";
$headers .= "Content-class: urn:content-classes:calendarmessage\r\n";
$headers .= "Content-type: text/calendar; method=REQUEST; charset=UTF-8\r\n";

$messaje = "BEGIN:VCALENDAR\r\n";
$messaje .= "VERSION:2.0\r\n";
$messaje .= "PRODID:PHP\r\n";
$messaje .= "METHOD:REQUEST\r\n";
$messaje .= "BEGIN:VEVENT\r\n";
$messaje .= "DTSTART:20121223T171010Z\r\n";
$messaje .= "DTEND:20121223T191010Z\r\n";
$messaje .= "DESCRIPTION: You have registered for the class\r\n";
$messaje .= "SUMMARY:Technical Training\r\n";
$messaje .= "ORGANIZER; CN=\"Corporate\":mailto:test@gmail.com\r\n";
$messaje .= "Location:" . $location . "\r\n";
$messaje .= "UID:040000008200E00074C5B7101A82E00800000006FC30E6 C39DC004CA782E0C002E01A81\r\n";
$messaje .= "SEQUENCE:0\r\n";
$messaje .= "DTSTAMP:".date('Ymd').'T'.date('His')."\r\n";
$messaje .= "END:VEVENT\r\n";
$messaje .= "END:VCALENDAR\r\n";
$message .= $messaje;
mail($to, $subject, $message, $headers);

答案 1 :(得分:0)

您缺少与您发送邀请的用户对应的ATTENDEE属性。见Outlook fails to recognize an ics message