HTML and Velocity Scripting

Anonymous
Not applicable

HTML and Velocity Scripting

Background:

I have an email that needs to be sent when an opportunity makes it to a certain stage in SFDC. Currently, this is all performed manually with Sendgrid.com (We are in the onboarding process with Marketo) and no data is entered into SFDC or Marketo. This email contains a bunch of links to social media ads to be approved by the client. These ads are made manually at this time, however, I am working with a developer to make the ads from SFDC data via API's. Then all the links will live in SFDC.

Not every email will have the same links so I need the email to be dynamic based on the field/token being null or not. So if there is a Facebook URL then the facebook icon should appear and be hyperlinked to the URL in the field, and if not it's hidden and another icon will show in its place.

HTML and Velocity:

Can I add all the HTML for the Icon and link to the Velocity token so there is not HTML for a blank area?

Something like..

##check if the field is blank

#if(${lead.FacebookLink} =! "")

##add link to email

#set($Facebook = "

<tr>

                                          <!--image-width:125px;height:125px-->

                                          <td class="padding_top" style="text-align:center;" valign="top">

                                            <div id="Features3ColCImgf6c43dde-6ec2-4b72-87f8-4a2c67c6e77a" mktoname="Features3ColCImg" class="mktoImg" mktolockimgsize="true">

                                              <a href="http://${lead.FacebookLink}" target="_blank"><img src="http://xxxxxxx.marketo.com/rs/xxx-xxx-xxx/images/facebook.jpg" width="125" style="" /></a>

                                            </div> </td>

                                        </tr>

                                        <!--Extra space-->

                                        <tr>

                                          <td height="${Features3Colspace-below-image}" style="line-height: 1px; font-size: 1px;"> </td>

                                        </tr>

                                        <tr>

                                          <td valign="top">

                                            <table cellpadding="0" cellspacing="0" border="0" width="100%" style="width: 100%; border-collapse: collapse;">

                                              <tbody>

                                                <tr>

                                                  <td valign="top" style="font-size:14px; color:${TextColor}; font-family:${TextFontFamily}; mso-line-height-rule: exactly; line-height:20px;text-align:center;">

                                                    <div class="mktoText" id="Features3ColCDescf6c43dde-6ec2-4b72-87f8-4a2c67c6e77a" mktoname="Features3ColCDesc">

                                                      <p><span style="color: #222222; font-family: Roboto, arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;

text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><strong>Facebook.com</strong> is an American online social media and social networking service company based in Menlo Park, California.</span><br /></p>

                                                    </div> </td>

                                                </tr>

")

#end

${Facebook}

Would I need the have the entirity of the email HTML in the velocity script? Since the email was based off a template will that add complications?

Lastly:

I was planning on using a default program and a smart campaign to handle the sends so when the link fields are not null and the opp has made it to the stage the email is sent at 5 pm that day. Is this the best practice