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
OlbrestOlbrest 

Email Template. How to insert dynamic data into email message ?

Hello, Sirs.

 

I have such Email template:

 

Dear {!Contact.FirstName},
Secret code is - {!??????????}

 

I must insert into email message my specific text message ( instead ???????? ).

 

 

 

Apex Code:

//AcID - Contact ID


//Eml - Email Template ID

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setReplyTo('support@force.com');
mail.setSenderDisplayName('Salesforce Support');
mail.setTargetObjectId(AcId);
mail.setTemplateId(EmlId);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

 

Which way I can do it ?


Thank you.

 

Message Edited by Olbrest on 03-04-2009 06:59 PM
Best Answer chosen by Admin (Salesforce Developers) 
ryan_marplesryan_marples
Check out page 428 of the Developer's Guide, it describes how this works and has code examples. The idea is that you can only use merge fields from the recipient object and the related-to object.

http://wiki.apexdevnet.com/index.php/Force_Platform_Developer_Guide

All Answers

ryan_marplesryan_marples
Check out page 428 of the Developer's Guide, it describes how this works and has code examples. The idea is that you can only use merge fields from the recipient object and the related-to object.

http://wiki.apexdevnet.com/index.php/Force_Platform_Developer_Guide
This was selected as the best answer
EmsEms

Ryan - Must one use a VisualForce email template to merge data from a custom object? It seems like this should be feasible with a regular HTML template and some Apex code too, but I can't find documentation on it anywhere... Any suggestions? Perhaps I should just get on with it and use a VisualForce Template. 

 

 

Thanks,

Emily