Is there a standard and an implementation for Icalendar event RSVP

爱⌒轻易说出口 提交于 2019-12-06 10:38:59

The following code will work with google calendar. The attachment is processed by gmail and acceptance is cascaded to the event.

$vcal = 'BEGIN:VCALENDAR
PRODID:-//EXAMPLE.NU//SE
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REPLY
BEGIN:VEVENT
DTSTART:20101215T160000Z
DTEND:20101215T170000Z
DTSTAMP:'.date('Ymd\THis\Z').'
ORGANIZER;CN=Jean-Charles:mailto:example@gmail.com
UID:u2coh5g3bppo2d2o3t@google.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;
 CN=user@example.se:mailto:user@example.se
CREATED:19000101T120000Z
DESCRIPTION:äåóö
LAST-MODIFIED:'.date('Ymd\THis\Z').'
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:a new test
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
';

$vcal = utf8_encode($vcal);

require('lib/phpmailer/class.phpmailer.php');
$mail = new PHPMailer();
$mail->AddAddress('example@gmail.com', 'Jean-Charles');
$mail->Body = "HTML BODY";
$mail->AltBody = "Text body";
$mail->Subject = "Email title";
$mail->Sender = "User Name";
$mail->FromName = "user@example.se";
$mail->AddStringAttachment($vcal, 'meeting.ics', "base64", "text/calendar");
$mail->Send();

The important bits are

  • Content-type : text/calendar
  • METHOD:REPLY
  • PARTSTAT:ACCEPTED|DECLINED
  • UID

I am not sure that it is necessary to send back all redundant information (description, summary, dtend, dtstart)

The following solution worked for me:

$mail->Subject = $name;
$mail->Body = $description; 
$mail->AltBody = $body; // ical format
$mail->Ical = $message; // ical format

This methods does not attach the ical format.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!