PHP - 将事件作为空闲时间发送到日历

PHP - send event to calendar as Free-Time

我有一个 php 代码,它生成并发送 outlook 事件。但它将用户状态设置为忙碌,我们不希望这样。我知道我可以将事件发送给某人并将状态设置为该事件的空闲时间。但是我不知道如何在我的代码中执行此操作。所以我的问题是,我需要更改哪个参数才能将事件状态设置为空闲时间?

代码:

$ical = 'BEGIN:VCALENDAR' . "\r\n" .
    'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "\r\n" .
    'VERSION:2.0' . "\r\n" .
    'METHOD:REQUEST' . "\r\n" .
    'BEGIN:VTIMEZONE' . "\r\n" .
    'TZID:Central Europe Standard Time' . "\r\n" .
    'BEGIN:STANDARD' . "\r\n" .
    'DTSTART:16011028T030000' . "\r\n" .
    'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10' . "\r\n" .
    'TZOFFSETFROM:+0200' . "\r\n" .
    'TZOFFSETTO:+0100' . "\r\n" .
    'END:STANDARD' . "\r\n" .
    'BEGIN:DAYLIGHT' . "\r\n" .
    'DTSTART:16010325T020000' . "\r\n" .
    'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3' . "\r\n" .
    'TZOFFSETFROM:+0100' . "\r\n" .
    'TZOFFSETTO:+0200' . "\r\n" .
    'END:DAYLIGHT' . "\r\n" .
    'END:VTIMEZONE ' . "\r\n" .
    'BEGIN:VEVENT' . "\r\n" .


    'ORGANIZER;CN="'.$name.'":MAILTO:'.$name. "\r\n" .
    'ATTENDEE;CN="'.$name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$name.','.$address.','.$address2.' ,'.$address3. "\r\n" .
    'LAST-MODIFIED:' . date("Ymd\TGis") . "\r\n" .
    'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."\r\n" .
    'DTSTAMP:'.date("Ymd\TGis"). "\r\n" .
    'DTSTART;TZID="Central Europe Standard Time":'.date("Ymd\THis", strtotime($startTime)). "\r\n" .
    'DTEND;TZID="Central Europe Standard Time":'.date("Ymd\THis", strtotime($endTime)). "\r\n" .
    'TRANSP:OPAQUE'. "\r\n" .
    'SEQUENCE:1'. "\r\n" .
    'SUMMARY:' . $subject . "\r\n" .
    'CLASS:PUBLIC'. "\r\n" .
    'PRIORITY:5'. "\r\n" .
    'BEGIN:VALARM' . "\r\n" .
    'TRIGGER:-PT15M' . "\r\n" .
    'ACTION:DISPLAY' . "\r\n" .
    'DESCRIPTION:Reminder' . "\r\n" .
    'END:VALARM' . "\r\n" .
    'END:VEVENT'. "\r\n" .
    'END:VCALENDAR'. "\r\n";

    $mail->Subject = "Invitation: Outlook Calendar Event";
    $mail->AddStringAttachment($ical, "event.ics", "7bit", "text/calendar; charset=utf-8; method=REQUEST");

    $mail->Body = "Test Outlook Calendar event mail";
    $mail->Ical = $ical;
    $mail->CharSet = 'UTF-8';

只需在您的 ical 中添加这一行并注明正确的日期和时间即可:

FREEBUSY;FBTYPE=FREE:[date start format Ymd]T[time start format Gis]Z/[date end format Ymd]T[time end format Gis]Z

例如: FREEBUSY;FBTYPE=BUSY:19980415T133000Z/19980415T170000Z

或者,如果它适用于 Outlook:

X-MICROSOFT-CDO-BUSYSTATUS:FREE

来源:

  1. https://icalendar.org/iCalendar-RFC-5545/3-2-9-free-busy-time-type.html
  2. https://docs.microsoft.com/en-us/openspecs/exchange_server_protocols/ms-oxcical/cd68eae7-ed65-4dd3-8ea7-ad585c76c736