I am trying to send meeting invite through php and all is woking fine, but meeting is displayed in my personal calendar and I want in to be visible in shared calendar. Can I set it up, so meeting will be written in another selected calendar? Or is there some parameter, where I can describe it?
My code:
function sendIcalEvent($address, $subject, $name, $datum_na_kdy, $datum_podani_pozadavku){
$domain = "@domain.com";
$startTime = "some date";
$endTime = "some date";
$mail = new PHPMailer();
$mail->SMTPAuth = true;
$mail->IsSMTP();
$mail->Host = "host.com"; // SMTP server
$mail->Username = "[email protected]";
$mail->Password = "********";
//$mail->SMTPSecure = 'tls';
$mail->Port = some-number;
$mail->AddAddress($address);
$mail->From = "[email protected]";
$mail->FromName = "Automat ";
$mail->ContentType = 'text/calendar';
$ical = 'BEGIN:VCALENDAR' . "rn" .
'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "rn" .
'VERSION:2.0' . "rn" .
'METHOD:REQUEST' . "rn" .
'BEGIN:VTIMEZONE' . "rn" .
'TZID:Eastern Time' . "rn" .
'BEGIN:STANDARD' . "rn" .
'DTSTART:20091101T020000' . "rn" .
'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "rn" .
'TZOFFSETFROM:-0400' . "rn" .
'TZOFFSETTO:-0500' . "rn" .
'TZNAME:EST' . "rn" .
'END:STANDARD' . "rn" .
'BEGIN:DAYLIGHT' . "rn" .
'DTSTART:20090301T020000' . "rn" .
'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "rn" .
'TZOFFSETFROM:-0500' . "rn" .
'TZOFFSETTO:-0400' . "rn" .
'TZNAME:EDST' . "rn" .
'END:DAYLIGHT' . "rn" .
'END:VTIMEZONE' . "rn" .
'BEGIN:VEVENT' . "rn" .
'ORGANIZER;CN="'.$name.'":MAILTO:'.$address. "rn" .
'ATTENDEE;CN="'.$name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$address. "rn" .
'LAST-MODIFIED:' . date("YmdTGis") . "rn" .
'UID:'.date("YmdTGis", strtotime($startTime)).rand()."@".$domain."rn" .
'DTSTAMP:'.date("YmdTGis"). "rn" .
'DTSTART;TZID="Eastern Time":'.date("YmdTHis", strtotime($startTime)). "rn" .
'DTEND;TZID="Eastern Time":'.date("YmdTHis", strtotime($endTime)). "rn" .
'TRANSP:OPAQUE'. "rn" .
'SEQUENCE:1'. "rn" .
'SUMMARY:' . $subject . "rn" .
'CLASS:PUBLIC'. "rn" .
'PRIORITY:5'. "rn" .
'BEGIN:VALARM' . "rn" .
'TRIGGER:-PT15M' . "rn" .
'ACTION:DISPLAY' . "rn" .
'DESCRIPTION:Reminder' . "rn" .
'END:VALARM' . "rn" .
'END:VEVENT'. "rn" .
'END:VCALENDAR'. "rn";
$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';
$message = NULL;
if(!$mail->Send()) {
$message = false;
} else {
$message = true;
}
return $message;
}