Home » PHP » iCalendar Generation
iCalendar Generation
One of my clients requested that the CRM applicationI wrote should interact with Outlook Calender.
For example, when adding a "Next Call Date" on the web based CRM application, the user's calendar is updated in Outlook so they are reminded even when not using the CRM application.
It should work for any VCalendar aware application, like Thunderbird & Lightning or Sunbird.
Heres how I did it, Create a file called make_calender.php
// Define the file as an iCalendar file
header("Content-Type: text/Calendar");
// Give the file a name and force download
header("Content-Disposition: inline; filename=calendar.ics");
// Header of ics file
echo "BEGIN:VCALENDARn";
echo "VERSION:2.0n";
echo "PRODID:PHPn";
echo "METHOD:REQUESTn";
echo "BEGIN:VEVENTn";
echo "SUMMARY: PUT SUMMARY DETAILS HERE n";
echo "DESCRIPTION: PUT DESCRIPTION DETAILS HERE";
echo "DTSTART:".DATE HERE."T090000n";
echo "DTEND:".DATE HERE."T090000n";
echo "UID: ".rand()."n";
echo "SEQUENCE:0n";
echo "DTSTAMP:".date('Ymd').'T'.date('His')."n";
echo "BEGIN:VALARMn";
echo "TRIGGER:-PT30Mn";
echo "REPEAT:1n";
echo "ACTION:DISPLAYn";
echo "END:VALARMn";
echo "END:VEVENTn";
echo "END:VCALENDARn";
You will need to populate the code with the following, presumably from a database record just before the above code.
Summary
echo "SUMMARY: PUT SUMMARY DETAILS HERE n";
Description
echo "DESCRIPTION: PUT DESCRIPTION DETAILS HERE";
Date & Time
echo "DTSTART:".DATE HERE."T090000n";
echo "DTEND:".DATE HERE."T090000n";
The code also produces a trigger, in Outlook terms, a reminder.
It will "alarm", in Outlook terms pop up a window, 30 minutes before the event.
This can be seen as
echo "BEGIN:VALARMn";
echo "TRIGGER:-PT30Mn";
echo "REPEAT:1n";
echo "ACTION:DISPLAYn";
echo "END:VALARMn";
This code will generate an ICS file that the user will be prompted to Open. Once opened Outlook will save the event.
Its upto you how you call it.
Further reading
Related posts
- WordPress Opengraph and Microdata Generation without a plugin
Its really useful to have Opengraph (Facebook) and Microdata (Twitter) information in your blog header.... - CAPTCHA Image Generation
I couldn't find a very good CAPTCHA generation script in PHP, all the ones I... - KB_CAPTCHA – CAPTCHA Image Generation in PHP
Introduction KB_Captcha is a simple PHP script to generate reasonably safe CAPTCHA image to secure... - CAPTCHA Image Generation Part 2
A quick morning hack - I added some random lines to try and confuse the... - Looping over dates in PHP
I recently had to loop over the difference between two dates. For example to create...
Categories
- 4PSA VoIPNow (1)
- Apache (20)
- APC (1)
- Automotive (7)
- Client Sites (10)
- cPanel/WHM (22)
- CubeCart (23)
- Domains (1)
- Exchange (6)
- Geeky (32)
- General (24)
- Home (1)
- HTML, CSS, AJAX (23)
- IIS (1)
- Linux (83)
- MS SQL (4)
- Music (5)
- MySQL (19)
- nginx (5)
- Photography (17)
- PHP (102)
- phpBB (1)
- Reviews (4)
- Scalability (1)
- Search Engines (5)
- Security (8)
- Snippets (4)
- Software (4)
- Uncategorized (6)
- Vantegra (1)
- Virtualisation (1)
- VoIP (3)
- WHMCS (1)
- Windows (42)
- WordPress (74)
- Shopp (14)
- Xen (2)
Recent Comments
- MUsh on Exchange 2003, 2007 & 2010 Topology discovery failed, error 0x80040a02 (DSC_E_NO_SUITABLE_CDC)
- Thomas on WordPress Opengraph and Microdata Generation without a plugin
- thiyagi on [Snippet] Create a large file in Linux
- Gopal Aggarwal on Multiple loops or making your own loop in WP-Ecommerce
- Ashique Zakariyya on Installing nginx & PHP-FPM securely on CentOS
Kieran Barnes
Independent PHP, WordPress and CubeCart programmer and consultant in Manchester, UK.
I can offer programming and consultancy for your next WordPress, Ecommerce or PHP web application.
About Kieran
Kieran is a PHP developer with 15 years commercial experience. He has a niche for all things WordPress, CubeCart and other open sourcery. With expertise in most areas of Linux and Windows wrangling makes him a good choice for supporting and consulting your next web application.
Get in Touch
Sitemap (HTML)
Sitemap (XML)


