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
cmxintcmxint 

Email template body with links: HOW TO?

Hi guys!

I need to create email template with links in the body. For example I want my email body to have name of account which would be not just a string but link (ordinary anchor: <a href=https://na1.salesforce.com/Account.ID>Account.Name</a>. Currently I'm generating email body programmatically (body={!Campaign_Description}, I fill in Campaign.Description field and then trigger workflow rule which sends email based on my custom email template. All this done programmatically). If I'm using ordinary Text-type email template and filling Campaign.Description field with string

    <a href=https://na1.salesforce.com/Account.ID>Account.Name</a>

than when I receive email its body is not recognized as HTML content and I see the whole string shown above with all tags - just plain text.

I tried to build Custom-type email template, but didn't achieve my point - I fill in Campaign.Description field with the same string but after receiving email I see that chars '<' and '>' are replaced with '&lt;' and '&gt;' respectively - smart action but I don't want that. As a result I see just plain text again - no link. .

So I wonder, is it possible in some way to get email which will contain links? May be my method of generating email body programmatically is not pretty good and some of you know better ways to accomplish that - please advice. Also may be you can advice how can I build merge template without programmatical building of its body and having links in it at the same time?

Any advices/comments/links are apreciated

DevAngelDevAngel

Hi cmxint,

Instead of typing an email into the template, you can enter a merge field like {!Account_Name} and then, highlight the entire merge field and click on the create hyperlink button and in the url field enter http://na1.salesforce.com/{!Account_ID}.

 

cmxintcmxint

Hi, Dave!

Thanks a lot for your advice - that's suitable enough for my purposes. Sorry for asking such essential questions (I'd better learn docs).

But now I have more complicated situation: my task is to send email notification after Account, Task or some custom objects owner changed. As for account - that's not a problem with your solution, but as for Task and custom objects... What I implemented for account is workflow rule which trigger on Account.SendEmail__c = true (I set it up via API when detect that account owner changed). Attaching alert and custom email template is a solution for account. But this solution can't be implemented neither for Tasks (since I can't paste Task merge fields into custom email template) nor for any custom objects (since workflow rules supports only standard SFDC objects). I'm about breaking my brain... So the question is: is it possible to implement such functionality at all? If so, could you please point out starting point I should begin further investigation with.

Any advices/comments/links are appreciated

DevAngelDevAngel

Hi cmxint,

Sounds like you will need to set up a watcher on task and custom objects.  You do this using the getupdated command.  To make this work, you will need to be able to determine that an owner changed.  The way to do this is to keep a list of tasks and their owner ids locally so that when a task is returned from the get updated, you can check to see if the ownerId changed.  If so, you can then create and send an email.  You will also need to keep you local list up to date by detecting when a new task has been created so that you can later detect ownership change.

 

cmxintcmxint

Hi, Dave!

I have already implemented watcher functionality - it works fine. What I need to do is to "create and send an email". This is a part I can't find solution for. In my previous post I tried to describe the source of problems I'm appearing with. The main of them - I can't access emails programmatically and, at the same time, I can't build them via SFDC to have them working correctly May be you have some ideas on how to create and send emails (with features from this topic)?

Thanks.

DevAngelDevAngel
smtp?
bmartinez76bmartinez76

I am having this issue and can't seem to find the insert a link icon. Can someone tell me where i can find it? Thank you. Below is a snapshot of what i see.

http://i235.photobucket.com/albums/ee28/bmartinez76/emailtemplate.jpg

bmartinez76bmartinez76

I was able to get this to work, but had to use word to create the template then paste it into salesforce.  The salesforce help is quite misleading because it has a resolution for this but it gives you steps to do as if you were in SF, not in a word editor.

 

Code:

<html>
<body>
The lead is from: <br><br>

{!Lead.FirstName} {!Lead.LastName} <br>
{!Lead.Company} {!Lead.Campaign} <br>
{!Lead.City}, {!Lead.State} <br>
<br>

Click on the link below to view the lead detail.  After viewing the lead please make sure to change the status to open or contacted depending on your follow-up. If the lead does not belong to you, please reassign to the appropriate AE under unread by owner status.<br>
<br>

Please view the Lead Detail now for more information. Thank you.<br>

<a href="https://ssl.salesforce.com/{!Lead.Id}">{!Lead.Link}</a>

</body>
</html>