Link to home
Start Free TrialLog in
Avatar of Shiva-Kumar
Shiva-Kumar

asked on

Php script to send email with outlook reminder

hi,

I am looking for a php script which would send an email with the appointment/reminder to the outlook calendar of the recepient.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of NerdsOfTech
NerdsOfTech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is excerpted from my church calendar.  Obviously untested code, since the data base lookups are not shown here, but hopefully the variable names make sense and you will get a good understanding of the moving parts.

I do not know if you have to URLencode() the event name or description - these are cleaned elsewhere in our scripts.

We do not send this via email - we just let the client click on a link to download the event directly from the web site into the outlook calendar.  But there is no reason I can think of that you could not send the x-vCalendar file as an attachment.

Best regards, ~Ray
<?php

// DATA BASE LOOKUP GETS EVENT INFORMATION ACCORDING TO THE $k VALUE

// GENERATE HEADER INFORMATION
$k = clean_integer($_GET["k"]);
$f = "NPCCEvent" . $k . ".vcs";

// FORMAT THE DATES LIKE THIS
$vcalstart = date("Ymd\THi00", strtotime($my_event_start));
$vcalend   = date("Ymd\THi00", strtotime($my_event_end));

// SEND THE HEADERS
header("Content-Type: text/x-vCalendar");
header("Content-Disposition: inline; filename=$f");

// SEND THE VCAL STRING WITH VARIABLE SUBSTITUTION FOR EVENT INFORMATION
?>
BEGIN:VCALENDAR
VERSION:1.0
PRODID:NPC Web Calendar
BEGIN:VEVENT
SUMMARY:<?php echo "$my_event_name" . PHP_EOL; ?>
DESCRIPTION;ENCODING=QUOTED-PRINTABLE: <?php echo "$my_event_description" . "=0D=0A" . PHP_EOL; ?>
DTSTART:<?php echo $vcalstart . PHP_EOL; ?>
DTEND:<?php echo $vcalend . PHP_EOL; ?>
END:VEVENT
END:VCALENDAR

Open in new window

Avatar of Shiva-Kumar
Shiva-Kumar

ASKER

Thank you