2

我设置了一个 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 语句重复此操作,但当然该事件会作为单独的电子邮件发送。

4

1 回答 1

2

在尝试了多种方法后,我想出了一个可行的解决方案。

  • 您需要将事件作为重复事件发送。
  • 第一个内部事件应该是默认事件。
  • 这应该包括指定重复频率和计数的 RRULE。
  • 这应该包含与第一天事件相同的 DTSTART、DTEND、DTSTAMP 值。
  • 包括默认事件在内的所有事件都应包含相同的 UID 和 SEQUENCE。
  • 除默认事件外,所有其他事件都应包含唯一的 RECURRENCE-ID。

有关更多详细信息,请参阅我写的关于解决方案的博客文章:http: //hasarangi.blogspot.com/2015/02/php-send-multiple-events-to-ms-outlook.html

于 2015-02-07T06:36:17.013 回答