function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sushmita Joshi 4Sushmita Joshi 4 

ICS markup in salesforce

Hi Experts,

I am working on a requirement wherein I need to send a confirmation mail with ICS attachment,on any even registartion and it should automatically block the outlook calender based on the event start and end date. I am now able to get the mail with ics attachment which contains Event name,Desription, Location Start date and End date. And start date is reflecting correctly in outlook calendar but if the event is for more than 1 day,its not taking the correct end date. Is there any parameter in ICS markup to specify series of events so that it blocks the calendar from start date to end date correctly. I have pasted the ICS template below.

     String [] icsTemplate = new List<String> {
                                              'BEGIN:VCALENDAR',
                                              'PRODID::-//hacksw/handcal//NONSGML v1.0//EN',
                                              'VERSION:2.0',
                                              'BEGIN:VEVENT',                                         
                                              'DTSTART : '+string.valueOf(startDateGMT),
                                              'DTEND: ' +string.valueOf(eDateGMT),
                                              'LOCATION: ' +location,
                                              'UID: ' +eventName,
                                              'DESCRIPTION: ' +eventDesription,
                                              'SUMMARY: ' +eventName,
                                              'BEGIN:VALARM',
                                              'TRIGGER:-PT15M',
                                              'ACTION:DISPLAY',
                                              'DESCRIPTION:'+eventDesription,
                                              'END:VALARM',
                                              'END:VEVENT',
                                              'END:VCALENDAR'
                                               };
            String attachment = String.join(icsTemplate, '\n'); 
           
           Messaging.EmailFileAttachment attach = New Messaging.EmailFileAttachment();
            attach.filename = 'Reminder.ics';
            attach.ContentType = 'text/Calender';
            attach.body = Blob.valueOf(attachment);
           email.setFileAttachments(new Messaging.EmailFileAttachment[] {attach});

I am getting the correct date and time in GMT format if I display startDateGMT and eDateGMT in console. 
format : 20170627T123000Z

Please let me know if I am missing something .

Thanks,
Sushmita Joshi