lionheart98
lionheart98

Reputation: 968

Sending meeting invitation using PHPMailer

I am trying to send meeting invitations to customers using PHPMailer. The *.ics files are generated dynamically using PHP (they aren't stored on the file system).

My iCalendar files look like the following:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ABC Corporation//Productname//EN
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
SEQUENCE:0
LAST-MODIFIED:20131023T120039ZUID:20131023T120039-29881-www.host.com
DTSTAMP:20131023T120039Z
DTSTART:20131102T083000Z
DTEND:20131102T084500Z
LOCATION:event location
SUMMARY;LANGUAGE=us-en:topic of the meeting 
DESCRIPTION: further information
ORGANIZER; CN="Organizer":mailto:[email protected]
BEGIN:VALARM
TRIGGER:-P1D
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR

Unfortunately, I just managed to add the *.ics file as an attachment yet.

$icalendar = new ICalendar();
$mail->AddStringAttachment($icalendar->genICalendar(), "meeting.ics", "base64", "text/calendar");

How can I send it as an outlook/gmail-styled invitation like the following? enter image description here

Any suggestions are greatly appreciated.

Upvotes: 0

Views: 4074

Answers (1)

Erik255
Erik255

Reputation: 1473

here is my solution for outlook i use it in an webproject since 2 Years

static $iCalContentType = "text/calendar";
    static $iCalContentDisposition = "inline; filename=calendar.vcs";
    static $iCalTmpl = "
BEGIN:VCALENDAR
METHOD:REQUEST
PRODID:MyApp
VERSION:2.0
BEGIN:VEVENT
STATUS:CONFIRMED
ORGANIZER;CN=\"AppNameMailer\":mailto:[email protected]
SUMMARY: __summary__
DESCRIPTION: \"__description__\"
COMMENT: none
DTSTART:__start__
DTEND:__end__
UID: __id__-AppName
SEQUENCE:__seq__
DTSTAMP:__now__
CLASS:PUBLIC
PRIORITY:5
TRANSP:OPAQUE
LOCATION:
BEGIN:VALARM
ACTION:DISPLAY
DESCRIPTION:REMINDER
TRIGGER;RELATED=START:-PT25M
END:VALARM
END:VEVENT
END:VCALENDAR
";

Works fine for me ! I just replace the __*__ Markers (take care there are no " ).

Ah and the correct time encoding is vital as far as i remember - has to be iso8601 (ending with Z)

hope it helps...

Upvotes: -1

Related Questions