如何在PHP中创建Outlook日历会议请求?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在PHP中创建Outlook日历会议请求?相关的知识,希望对你有一定的参考价值。

有人能指出我正确的方向吗?我知道它与附加一个.ics文件有关,但我只能将它发送到用户可以下载然后将事件导入Outlook日历的程度?如何以编程方式创建这些会议请求?

答案

以下是多个参与者的工作示例:

<?php

    $to = 'boushh@arturito.net,bobafett@arturito.net';
    $subject = "Millennium Falcon";

    $organizer          = 'Darth Vader';
    $organizer_email    = 'darthvader@arturito.net';

    $participant_name_1 = 'Boushh';
    $participant_email_1= 'boushh@arturito.net';

    $participant_name_2 = 'Boba Fett';
    $participant_email_2= 'bobafett@arturito.net';  

    $location           = "Stardestroyer-013";
    $date               = '20131026';
    $startTime          = '0800';
    $endTime            = '0900';
    $subject            = 'Millennium Falcon';
    $desc               = 'The purpose of the meeting is to discuss the capture of Millennium Falcon and its crew.';

    $headers = 'Content-Type:text/calendar; Content-Disposition: inline; charset=utf-8;
';
    $headers .= "Content-Type: text/plain;charset="utf-8"
"; #EDIT: TYPO

    $message = "BEGIN:VCALENDAR

    VERSION:2.0

    PRODID:-//Deathstar-mailer//theforce/NONSGML v1.0//EN

    METHOD:REQUEST

    BEGIN:VEVENT

    UID:" . md5(uniqid(mt_rand(), true)) . "example.com

    DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z

    DTSTART:".$date."T".$startTime."00Z

    DTEND:".$date."T".$endTime."00Z

    SUMMARY:".$subject."

    ORGANIZER;CN=".$organizer.":mailto:".$organizer_email."

    LOCATION:".$location."

    DESCRIPTION:".$desc."

    ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_1.";X-NUM-GUESTS=0:MAILTO:".$participant_email_1."

    ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_2.";X-NUM-GUESTS=0:MAILTO:".$participant_email_2."

    END:VEVENT

    END:VCALENDAR
";

    $headers .= $message;
    mail($to, $subject, $message, $headers);    
?>

如果您需要添加/删除选项,请参阅VCALENDAR:VCALENDAR on Wikipedia

另一答案

您可以以编程方式生成.ics :)

这是如何做:

<?php
    $date      = $_GET['date'];
    $startTime = $_GET['startTime'];
    $endTime   = $_GET['endTime'];
    $subject   = $_GET['subject'];
    $desc      = $_GET['desc'];

    $ical = "BEGIN:VCALENDAR
    VERSION:2.0
    PRODID:-//hacksw/handcal//NONSGML v1.0//EN
    BEGIN:VEVENT
    UID:" . md5(uniqid(mt_rand(), true)) . "example.com
    DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z
    DTSTART:".$date."T".$startTime."00Z
    DTEND:".$date."T".$endTime."00Z
    SUMMARY:".$subject."
    DESCRIPTION:".$desc."
    END:VEVENT
    END:VCALENDAR";

    //set correct content-type-header
    header('Content-type: text/calendar; charset=utf-8');
    header('Content-Disposition: inline; filename=calendar.ics');
    echo $ical;
    exit;
?>

以上是关于如何在PHP中创建Outlook日历会议请求?的主要内容,如果未能解决你的问题,请参考以下文章

接受请求后 Outlook 日历从收件箱中消失

未在服务帐户谷歌日历 api php 中创建环聊链接

是否有 VBA 方法可以在 Outlook 中创建新日历(不是约会)

c#在默认的另一个日历中添加会议请求

如何在Bluemix Node-Red Application中发送会议邀请(日历)[关闭]

查看 Google 日历中创建的每个活动的会议链接