I am a non-developer Admin and am hoping for help! I am trying to add a text/Javascipt block to a Visualforce email template, which will render an Add to Calendar button. The code block below will save, but not show the button I expect. All the text in the < span > lines show as text and don't render as a part of the javascript. As you can tell, I'm a novice! Please help!

<script type="text/javascript" src="https://addevent.com/libs/atc/1.6.1/atc.min.js" async defer></script>


<div title="Add to Calendar" class="addeventatc">
    Add to Calendar
    <span class="start">03/01/2018 08:00 AM</span>
    <span class="end">03/01/2018 10:00 AM</span>
    <span class="timezone">America/Los_Angeles</span>
    <span class="title">Summary of the event</span>
    <span class="description">Description of the event</span>
    <span class="location">Location of the event</span>


2 Answers 2


I recommend searching the visualforce email template documentation provided by salesforce to see if putting javascript in vf email templates is feasible. If it is then read about javascript (js) functions and how to get them to do stuff when element IDs are clicked. You can read about HTML buttons and build one with this syntax <button id=“someUniqueId”> Click me </button> and then between your script tags youll want a javascript function that listens for (responds to) clicks made to the page element whose ID = “someUniqueId”. Example of js button click script: https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onclick Hope that helps!


In emails/newsletters, you can only use text, links, and images. The "Add to Calendar" button consists of HTML, CSS, Javascript, and Javascript won't run inside an email (security reasons).

For newsletters, you can use the "Events" tool which enables you to add text links to your email.


You must log in to answer this question.

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