Skip to content

Instantly share code, notes, and snippets.

@douglascayers
Last active April 14, 2025 04:54
Show Gist options
  • Save douglascayers/ada5a2a1708099f6ed7e to your computer and use it in GitHub Desktop.
Save douglascayers/ada5a2a1708099f6ed7e to your computer and use it in GitHub Desktop.
Create .ics Calendar Event in Visualforce
<!--
Simple proof-of-concept to create a .ics calendar event with visualforce.
Inspired by Natalie Regier @gnatrae
This example uses url parameters to set the details of event.
You could create a custom button that invokes this page, like:
https://<your-salesforce-domain>/apex/vCalendarPage?start={!TEXT(Obj.StartDate__c)}&end={!TEXT(Obj.EndDate__c)}&subject=Event from Visualforce&description=This .ics event created with visualforce&location=The Cloud
An example with literal values you can copy & paste in your browser:
https://<your-salesforce-domain>/apex/vCalendarPage?start=20140524T140000&end=20140524T153000&subject=Event from Visualforce&description=This .ics event created with visualforce&location=The Cloud
-->
<apex:page title="event.ics" contentType="text/calendar" cache="false">
BEGIN:VCALENDAR
VERSION:2.0
PRODID::-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
DTSTAMP;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($CurrentPage.parameters.start,':',''),'-',''),' ','T')}"/>
UID:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($CurrentPage.parameters.start,':',''),'-',''),' ','')}"/>[email protected]
DTSTART;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($CurrentPage.parameters.start,':',''),'-',''),' ','T')}"/>
DTEND;TZID=GMT:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($CurrentPage.parameters.end,':',''),'-',''),' ','T')}"/>
SUMMARY:<apex:outputText value="{!$CurrentPage.parameters.subject}"/>
DESCRIPTION:<apex:outputText value="{!$CurrentPage.parameters.description}"/>
LOCATION:<apex:outputText value="{!$CurrentPage.parameters.location}"/>
END:VEVENT
END:VCALENDAR
</apex:page>
@gauravg-metacube
Copy link

@douglascayers Can we provide the latest link as existing link is not working.

@avi4r10
Copy link

avi4r10 commented Apr 14, 2025

@gauravg-metacube @johndturn @AvelinoOktana @ajhare
Please check this link https://www.sfdcstacks.com/2025/04/send-emails-with-calendar-invites.html, similar implementation without vf. Just plain Apex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment