Welcome to TouSu Developer Zone-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

How to create an outlook calendar meeting request in PHP?

Can someone point me in the right direction? I know it has to do with attaching a .ics file, but I can only get it to the point where a user can download and then import the event into their outlook calendar? How can I programmatically create these meeting requests?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is working example with multiple participants:

<?php

    $to = '[email protected],[email protected]';
    $subject = "Millennium Falcon";

    $organizer          = 'Darth Vader';
    $organizer_email    = '[email protected]';

    $participant_name_1 = 'Boushh';
    $participant_email_1= '[email protected]';

    $participant_name_2 = 'Boba Fett';
    $participant_email_2= '[email protected]';  

    $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);    
?>

If you need to add/remove options here is a reference of VCALENDAR: VCALENDAR on Wikipedia


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to TouSu Developer Zone-Open, Learning and Share
Click Here to Ask a Question

...