+ Start a Discussion
Scott0987Scott0987 

email list of accounts

Here is the situation.   I have a list of account ID's.  I want to send en email to an email field on each of those accounts.  I have a visualforce template that I want to use as the body of the email.  How do I get the email to go out to each of the accounts and have the fields referenced on the template apply to the account that he email is set to go to?  Maybe I am just overthinking this, but any help would be appreciated, I am expirienced with apex but have never used the email portion of it before.  Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
Praful GadgePraful Gadge

Hi Scott,

 

Here is some example code to get you started.

 

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(*put id of template here*);
mail.setwhatid(*put id of object record here*);

 

Check out the documentation on APEX Email Classes HERE  .

If this post is your solution, kindly mark this as the solution to the post so that others may benefit.

 

Regards,

Praful G.

All Answers

Praful GadgePraful Gadge

Hi Scott,

 

Here is some example code to get you started.

 

 

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setTemplateId(*put id of template here*);
mail.setwhatid(*put id of object record here*);

 

Check out the documentation on APEX Email Classes HERE  .

If this post is your solution, kindly mark this as the solution to the post so that others may benefit.

 

Regards,

Praful G.

This was selected as the best answer
Scott0987Scott0987

Thank you for this help.  Between thehelp you gave me, the link you gave me and This Page I was able to figure it all out.