Reputation: 1
I'm trying to send a meeting request with an Ical and PhpMailer. I join the Ical as a StringAttachment with my mail. If i download the attachment, i can read it with a desktop Outlook but i try to open it with Office 365 and i have an alert that say : "The .ICS attachment can't be viewed because the format is not supported.". On google calendar i can't import it either.
$ical = "BEGIN:VCALENDAR\r\n";
$ical .= "VERSION:2.0\r\n";
$ical .= "METHOD:REQUEST\r\n";
$ical .= "BEGIN:VEVENT\r\n";
$ical .= "BEGIN:VTIMEZONE\r\n";
$ical .= "TZID:Europe/Paris\r\n";
$ical .= "X-LIC-LOCATION:Europe/Paris\r\n";
$ical .= "BEGIN:DAYLIGHT\r\n";
$ical .= "TZOFFSETFROM:+0100\r\n";
$ical .= "TZOFFSETTO:+0200\r\n";
$ical .= "TZNAME:CEST\r\n";
$ical .= "DTSTART:19700329T020000\r\n";
$ical .= "RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3\r\n";
$ical .= "END:DAYLIGHT\r\n";
$ical .= "BEGIN:STANDARD\r\n";
$ical .= "TZOFFSETFROM:+0200\r\n";
$ical .= "TZOFFSETTO:+0100\r\n";
$ical .= "TZNAME:CET\r\n";
$ical .= "DTSTART:19701025T030000\r\n";
$ical .= "RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10\r\n";
$ical .= "END:STANDARD\r\n";
$ical .= "END:VTIMEZONE\r\n";
$ical .= "ORGANIZER:MAILTO:[email protected]\r\n";
$ical .= "ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:[email protected]\r\n";
$ical .= "UID:".strtoupper(md5($interId))."-*****.fr\r\n";
$ical .= "METHOD:REQUEST\r\n";
$ical .= "SEQUENCE:1";
$ical .= "STATUS:".$status."\r\n";
$ical .= "DTSTART:".$startDate->format('Ymd').'T'.$startDate->format('His')."\r\n";
$ical .= "DTEND:".$endDate->format('Ymd').'T'.$endDate->format('His')."\r\n";
$ical .= "LOCATION:".$shopName."\r\n";
$ical .= "SUMMARY:".$summary."\r\n";
$ical .= "DESCRIPTION:\r\n";
$ical .= "BEGIN:VALARM\r\n";
$ical .= "TRIGGER:-PT15M\r\n";
$ical .= "ACTION:DISPLAY\r\n";
$ical .= "DESCRIPTION:Reminder\r\n";
$ical .= "END:VALARM\r\n";
$ical .= "END:VEVENT\r\n";
$ical .= "END:VCALENDAR\r\n";
$mail->AddStringAttachment($ical, "Invite.ics", "base64", "text/calendar; charset=utf-8; method=REQUEST");
I want the invite to be readable by gmail and office 365, but I don't understand what's wrong with my ical. Do you have any ideas?
Thanks
Upvotes: 0
Views: 1168
Reputation: 1
Your second error is likely caused by the METHOD property inside the VEVENT component. METHOD should only occur inside the VCALENADAR component.
Upvotes: -1
Reputation: 35331
A couple problems:
1) The DTSTART and DTEND properties in the VEVENT component are missing the TZID parameter.
$ical .= "DTSTART;TZID=Europe/Paris:".$startDate->format('Ymd').'T'.$startDate->format('His')."\r\n";
$ical .= "DTEND;TZID=Europe/Paris:".$endDate->format('Ymd').'T'.$endDate->format('His')."\r\n";
2) The VTIMEZONE component should not be inside of the VEVENT component. It should be underneath the VCALENDAR component.
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REQUEST
BEGIN:VTIMEZONE
...
END:VTIMEZONE
BEGIN:VEVENT
...
END:VEVENT
END:VCALENDAR
Upvotes: 1