通过iCalendar向管理器的Outlook添加约会

时间:2018-03-06 21:21:15

标签: php outlook phpmailer icalendar vcalendar

我的情况:约会存储在外部CMS中。我想将约会(通过PHP / PHPMailer)发送给最终用户的邮件客户端(Outlook)。用户(组织者)应该能够将约会发送给他自己和其他与会者,而他(组织者)应该得到与会者的所有回复。

我可以将约会发送给所有用户(组织者和与会者),但如果约会者回复约会,组织者将收到通知,但组织者日历条目将无法看到。他甚至没有看到“跟踪”系统来观察接受或拒绝邀请的人。

很难描述,但希望我的问题得到澄清。

这是我的设置:

$mail = new \PHPMailer();
$mail->isSMTP();                  
$mail->isHTML(false);
// Settings...
$mail->ContentType = 'text/calendar';
$mail->addCustomHeader('MIME-version',"1.0");
$mail->addCustomHeader('Content-type',"text/calendar; method=REQUEST; charset=UTF-8");
$mail->addCustomHeader('Content-Transfer-Encoding',"7bit");
$mail->addCustomHeader('X-Mailer',"Microsoft Office Outlook 12.0");
$mail->addCustomHeader("Content-class: urn:content-classes:calendarmessage");

$mail->AddAddress('organizer@example.com');
$mail->AddAddress('attendent@example.com');

// Event data
$summary = 'Test event';
$location = 'Room 001';
$start = '20180310';
$start_time = '160000';
$end = '20180310';
$end_time = '163000';
$event_id = 123456;
$sequence = 0;
$status = 'CONFIRMED';

$mail->Subject = $summary";

$ical = "BEGIN:VCALENDAR\r\n";
$ical .= "VERSION:2.0\r\n";
$ical .= "PRODID:-//Company//Anything//DE\r\n";
$ical .= "METHOD:REQUEST\r\n";
$ical .= "BEGIN:VEVENT\r\n";
$ical .= ORGANIZER;CN=\"Organizer\":MAILTO:organizer@example.com\r\n";
$ical .= "ATTENDEE;CN=\"Anybody\";ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:MAILTO:attendent@example.com\r\n";
$ical .= "UID:" . strtoupper(md5($event_id)) . "-example.com\r\n";
$ical .= "SEQUENCE:" . $sequence . "\r\n";
$ical .= "STATUS:" . $status . "\r\n";
$ical .= "DTSTAMPTZID=Europe/Berlin:" . date('Ymd') . 'T' . date('His') . "\r\n";
$ical .= "DTSTART:" . $start . "T" . $start_time . "\r\n";
$ical .= "DTEND:" . $end . "T" . $end_time . "\r\n";
$ical .= "LOCATION:" . $location . "\r\n";
$ical .= "SUMMARY:" . $summary . "\r\n";
$ical .= "DESCRIPTION:AnyText\r\n";
$ical .= "BEGIN:VALARM\r\n";
$ical .= "TRIGGER:-PT15M\r\n";
$ical .= "ACTION:DISPLAY\r\n";
$ical .= "DESCRIPTION:Reminder\r\n";
$ical .= "END:VALARM\r\n";
$ical .= "END:VEVENT\r\n";
$ical .= "END:VCALENDAR\r\n";

// Send mail via PHPMailer...

有关如何将活动放入组织者日历(来自外部应用程序)的任何建议,然后谁能够收到与会者的回复?

1 个答案:

答案 0 :(得分:0)

首先,我建议使用an ical builder class,而不是手动滚动自己。

PHPMailer有一些built-in iCal support可以让它变得简单:

$ical = "your ical data in here, generated however you like";
$mail->Ical = $ical;

请注意,客户端的iCal支持变化很大;很难让iCal元素同时在gmail和Outlook中运行。