Home > OS >  PHP - send event to calendar as Free-Time
PHP - send event to calendar as Free-Time

Time:06-02

I have a php code, that generates and sends outlook event. But it sets user status as Busy and we dont want that. I know that I can send event to someone and set status as free time for that event. But I have no idea, how to do it in my code. So my question is, which parameter I need to change, to set event status as free time?

Code :

$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';

CodePudding user response:

Just add this line in your ical with the right date and time :

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

e.g. : FREEBUSY;FBTYPE=BUSY:19980415T133000Z/19980415T170000Z

Or, if it's for Outlook :

X-MICROSOFT-CDO-BUSYSTATUS:FREE

sources :

  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
  • Related