3

Can anyone provide me a sample .ics(google,iCalendar etc) which i can attach to my email template from salesforce.

I've tried a lot with help of the google. I'm unable to get google Button format when i attach it to the email template(standard).

Thank you advance.

1
  • If you want to get Add to calendar button in gmail, post start date and end date along with time.
    – Rv1
    Aug 16, 2017 at 16:37

1 Answer 1

3
<a href="http://www.google.com/calendar/event?action=TEMPLATE&text=Inspection%20for%20{!relatedTo.Street__c}&dates={! SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.Inspection_Date__c),':',''),'-','')}T{!IF(OR(CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '10'), CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '11'), CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '12')), LEFT(relatedTo.Inspection_Start_Time_Only__c, 2), IF(CONTAINS(relatedTo.Inspection_Start_Time_Only__c, 'AM'), '0' & LEFT(relatedTo.Inspection_Start_Time_Only__c, 1), VALUE(LEFT(relatedTo.Inspection_Start_Time_Only__c, 1)) + 12))}{!LEFT(RIGHT(relatedTo.Inspection_Start_Time_Only__c, 5),2)}00/{! SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.Inspection_Date__c),':',''),'-','')}T{!IF(OR(CONTAINS(relatedTo.Inspection_End_Time_Only__c, '10'), CONTAINS(relatedTo.Inspection_End_Time_Only__c, '11'), CONTAINS(relatedTo.Inspection_End_Time_Only__c, '12')), LEFT(relatedTo.Inspection_End_Time_Only__c, 2), IF(CONTAINS(relatedTo.Inspection_End_Time_Only__c, 'AM'), '0' & LEFT(relatedTo.Inspection_End_Time_Only__c, 1), VALUE(LEFT(relatedTo.Inspection_End_Time_Only__c, 1)) + 12))}{!LEFT(RIGHT(relatedTo.Inspection_End_Time_Only__c, 5),2)}00&details=Inspection%20Scheduled%20on%20{! TEXT(relatedTo.Inspection_Date__c)}%20for%20Client%20{!relatedTo.Client_Name__c}&location={! SUBSTITUTE(relatedTo.Address_For_Email_Templates__c, '<br>', ', ')}"
                                                               style="display:inline-block;padding:10px 20px 10px 50px;border:2px solid #78C339;text-decoration:none;font-size:13px;color:#78C339;border-radius:20px;font-family: Helvetica, arial, sans-serif;background-image:url({!$Label.Calendar_Icon_Link});background-repeat:no-repeat;background-position:20px 10px;background-size:21px 19px;">
                                                               <span style="line-height:19px;height:19px;vertical-align:middle;display:inline-block;">Add to Google Calendar</span>
                                                            </a>



<messaging:attachment filename="AddToCalendar.ics">BEGIN:VCALENDAR
VERSION:2.0
PRODID::-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
DTSTAMP:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.Inspection_Date__c),':',''),'-','')}"/>T{!IF(OR(CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '10'), CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '11'), CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '12')), LEFT(relatedTo.Inspection_Start_Time_Only__c, 2), IF(CONTAINS(relatedTo.Inspection_Start_Time_Only__c, 'AM'), '0' & LEFT(relatedTo.Inspection_Start_Time_Only__c, 1), VALUE(LEFT(relatedTo.Inspection_Start_Time_Only__c, 1)) + 12))}{!LEFT(RIGHT(relatedTo.Inspection_Start_Time_Only__c, 5),2)}00
UID:<apex:outputText value="{!relatedTo.id}"/>
DTSTART:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.Inspection_Date__c),':',''),'-','')}"/>T{!IF(OR(CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '10'), CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '11'), CONTAINS(relatedTo.Inspection_Start_Time_Only__c, '12')), LEFT(relatedTo.Inspection_Start_Time_Only__c, 2), IF(CONTAINS(relatedTo.Inspection_Start_Time_Only__c, 'AM'), '0' & LEFT(relatedTo.Inspection_Start_Time_Only__c, 1), VALUE(LEFT(relatedTo.Inspection_Start_Time_Only__c, 1)) + 12))}{!LEFT(RIGHT(relatedTo.Inspection_Start_Time_Only__c, 5),2)}00
DTEND:<apex:outputText value="{!SUBSTITUTE(SUBSTITUTE(TEXT(relatedTo.Inspection_Date__c),':',''),'-','')}"/>T{!IF(OR(CONTAINS(relatedTo.Inspection_End_Time_Only__c, '10'), CONTAINS(relatedTo.Inspection_End_Time_Only__c, '11'), CONTAINS(relatedTo.Inspection_End_Time_Only__c, '12')), LEFT(relatedTo.Inspection_End_Time_Only__c, 2), IF(CONTAINS(relatedTo.Inspection_End_Time_Only__c, 'AM'), '0' & LEFT(relatedTo.Inspection_End_Time_Only__c, 1), VALUE(LEFT(relatedTo.Inspection_End_Time_Only__c, 1)) + 12))}{!LEFT(RIGHT(relatedTo.Inspection_End_Time_Only__c, 5),2)}00
SUMMARY:<apex:outputText value="Inspection for {!relatedTo.Street__c}"/>
DESCRIPTION:<apex:outputText value="Inspection Scheduled on {! TEXT(relatedTo.Inspection_Date__c)} at {!relatedTo.Inspection_Start_Time_Only__c} for Client {!relatedTo.Client_Name__c}" escape="false"/>
LOCATION:<apex:outputText value="{! SUBSTITUTE(relatedTo.Address__c, '<br>', ', ')}" escape="false"/>
BEGIN:VALARM
TRIGGER:-PT1D
ACTION:DISPLAY
DESCRIPTION:Reminder
END:VALARM
END:VEVENT
END:VCALENDAR 
</messaging:attachment>
1
  • Thank you for your code. But, above code is not displaying 'Add to calendar' button in my gmail account. Any idea on how to achieve it.
    – Rv1
    Aug 2, 2017 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .