我设置了一个 PHP 文件来向 Outlook/Vcalendar 发送事件邀请,如下所示:
<?php
$message="
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130901T121000Z
DTEND:20130901T131000Z
DTSTAMP:20110525T075116Z
ORGANIZER;CN=From Name:mailto:from email id
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Sample:emailaddress@testemail.com
DESCRIPTION:Test the first invite
LOCATION: Test Location
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Test the first icalendar invitation
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR";
/*headers*/
$headers = "From: From Name <From Mail>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST;\n";
$headers .= ' charset="UTF-8"';
$headers .= "\n";
$headers .= "Content-Transfer-Encoding: 7bit";
/*mail content*/
$subject = "Meeting Subject";
$subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
/*mail send*/
if(mail("emailaddress@testemail.com", $subject, $message, $headers))
{
echo "Your request has been sent";
}else {
echo "error";
}
?>
这工作正常。一封电子邮件会发送到 Outlook,打开后,该事件会自动发布到相关日历中。
有谁知道是否可以发送多个事件,这些事件将在打开 *单个 *电子邮件时全部发布。
我尝试如下重复 vcalendar 事件,但只有第一个事件被发布。
<?php
$message="
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130901T121000Z
DTEND:20130901T131000Z
DTSTAMP:20110525T075116Z
ORGANIZER;CN=From Name:mailto:from email id
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Sample:emailaddress@testemail.com
DESCRIPTION:Test the first invite
LOCATION: Test Location
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Test the first icalendar invitation
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART:20131001T121000Z
DTEND:20131001T131000Z
DTSTAMP:20110525T075116Z
ORGANIZER;CN=From Name:mailto:from email id
UID:12345678
ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Sample:emailaddress@testemail.com
LOCATION: Test the second location
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Test the second icalendar invitation
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR";
/*headers*/
$headers = "From: From Name <From Mail>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/calendar; method=REQUEST;\n";
$headers .= ' charset="UTF-8"';
$headers .= "\n";
$headers .= "Content-Transfer-Encoding: 7bit";
/*mail content*/
$subject = "Meeting Subject";
$subject = html_entity_decode($subject, ENT_QUOTES, 'UTF-8');
/*mail send*/
if(mail("emailaddress@testemail.com", $subject, $message, $headers))
{
echo "Your request has been sent";
}else {
echo "error";
}
?>
我还尝试将每个日历事件封装为单独的声明(即 $message2 等),然后使用 if 语句重复此操作,但当然该事件会作为单独的电子邮件发送。