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
peterg012peterg012 

Email Template Design

Hi,

 

Been looking around for an answer to this.   Is it possible have an email template that a section within it gets populated with say a list of contacts in the body of it?  Basically the template body needs to display a list of contacts from a query? 

 

Thanks in advance

Peter

 

 

sebcossebcos

Hi Peter,

you can use visualforce email templates to deliver this functionality, find a simple example here:

http://wiki.developerforce.com/index.php/VisualForceEmailTemplates_sample .

 

If you need to invoke apex within your template the visualforce dev guide shows how:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_templates_with_apex.htm 

 

There is also a post that shows an example of this technique:

http://boards.developerforce.com/t5/Visualforce-Development/Possible-to-do-basic-math-in-a-visualforce-email-template-or-is/m-p/132911?jump=true#M14004 .

 

 

peterg012peterg012

Hi Thanks very much., will look at these. I forgot to mention in my earlier post, is this possible in the Bulk API?

sebcossebcos

Hi,

I believe you are referring to the REST API.

This API can be used by external clients to connect to Force.com database. You can retrieve data in the form of Json and XML but this data is not sent via email but via HTTP protocol. You need to build a tool outside of the Force.com platform to send the emails with this data.

To get an introduction to the REST API: http://www.salesforce.com/us/developer/docs/api_rest/index.htm .

Also, look at this coming feature regarding Bulk API queries, which is currently in pilot:

http://blog.sforce.com/sforce/2011/03/bulk-api-queries.html

peterg012peterg012

Hi,

 

We have a few classes in APEX that use bulk / batch e.g. in a trigger.  But we need to be able to send the email to contacts in the previously mentioned manner, where we are trying to dynamically populate an email template body section with multiple record data.

 

"The Bulk API is based on REST principles, and is optimized for loading or deleting large sets of data. It allows you to insert, update, upsert, or delete a large number of records asynchronously by submitting a number of batches which are processed in the background by Salesforce.".

 

Thanks

Peter Guest