【问题标题】:How to create an outlook calendar meeting request in PHP?如何在 PHP 中创建 Outlook 日历会议请求?
【发布时间】:2012-10-08 06:01:57
【问题描述】:

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

【问题讨论】:

    标签: php outlook icalendar


    【解决方案1】:

    这是一个有多个参与者的工作示例:

    <?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;\r\n';
        $headers .= "Content-Type: text/plain;charset=\"utf-8\"\r\n"; #EDIT: TYPO
    
        $message = "BEGIN:VCALENDAR\r\n
        VERSION:2.0\r\n
        PRODID:-//Deathstar-mailer//theforce/NONSGML v1.0//EN\r\n
        METHOD:REQUEST\r\n
        BEGIN:VEVENT\r\n
        UID:" . md5(uniqid(mt_rand(), true)) . "example.com\r\n
        DTSTAMP:" . gmdate('Ymd').'T'. gmdate('His') . "Z\r\n
        DTSTART:".$date."T".$startTime."00Z\r\n
        DTEND:".$date."T".$endTime."00Z\r\n
        SUMMARY:".$subject."\r\n
        ORGANIZER;CN=".$organizer.":mailto:".$organizer_email."\r\n
        LOCATION:".$location."\r\n
        DESCRIPTION:".$desc."\r\n
        ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_1.";X-NUM-GUESTS=0:MAILTO:".$participant_email_1."\r\n
        ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE;CN".$participant_name_2.";X-NUM-GUESTS=0:MAILTO:".$participant_email_2."\r\n
        END:VEVENT\r\n
        END:VCALENDAR\r\n";
    
        $headers .= $message;
        mail($to, $subject, $message, $headers);    
    ?>
    

    如果您需要添加/删除选项,这里是 VCALENDAR 的参考: VCALENDAR on Wikipedia

    【讨论】:

    • 感谢您让主题与您的用户名和个人资料图片保持一致
    【解决方案2】:

    您可以以编程方式生成 .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;
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-02
      • 1970-01-01
      • 1970-01-01
      • 2017-06-10
      • 2016-09-25
      • 1970-01-01
      • 2012-03-13
      • 2023-03-18
      相关资源
      最近更新 更多