Chris
Chris

Reputation: 814

How to send iCal with PHPMailer

I am using the latest version of PHPMailer 5.2.7 and I would like to send an iCal event generated using the PHP class iCalcreator

I could not find any documentation on how how to send an iCal. Does anyone have an example?

Upvotes: 0

Views: 6261

Answers (2)

Denis Giffeler
Denis Giffeler

Reputation: 1509

Once you generated the syntactically correct iCal code you just add the new file as an attachment:

$mailer->addAttachment('/path/to/your/file/schedule.ics', 'alternativename.ics', 'base64', 'text/calendar');

You may provide an alternative name for the original file. If the ICS data is in a string-object you can use $mailer->AddStringAttachment(...).

Upvotes: 2

dabo2100
dabo2100

Reputation: 88

You can create manually the iCal code and then attached to the email (as attachment or inline). All you need to do after that is assign your ical string to the mail->iCal variable. Ex.

include_once("phpMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->Body = $description; // Your HTML decsription
$mail->AltBody = $description; // For non HTML email client
$mail->Ical = $ical; //Your manually created ical code

I was able to send iCal event inside the email, as inline. Also sending files attachment and keep the ical inside the email.

Upvotes: 0

Related Questions