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
mworld2mworld2 

VF Email Templates

I am an expereinced VF and APEX Developer working with email generation for the first time.

 

My client wants to send a recap of appointment activity to an email distribution list, some of the members of which are SF users and some are not. This recap is generated by the user upon selection of a date range and account name. This recap is sent to a VF page for preview by the user. I would like to integrate this display code into a VF Email template and then send it to the distribution list.

 

Can VF Email Templates be used to send email to a list of email addresses, rather than a list of Contacts, Users, or Leads? The examples I have seen are confusing.

 

Thanks!

 

Mauricio

ahab1372ahab1372

you cannot specify recipients in the vf email template itself.

You can create and send the email completely in the controller of the VF page based on the VF page input, not using templates at all. Check out the email class in the apex docu:  http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_classes_email_outbound.htm

 

Maybe you can recycle the output of the VF page and use that for the setHtmlBody() of the email with

myEmail.setHtmlBody()

 

 

---your code to create the email myEmail----

PageReference myVFPageRef = Page.myVFPage;
myVFPageRef.getParameters().put(---your parameters here--);
string htmlBody= myVFPageRef.getContent();

myEmail.setHtmlBody(htmlBody);