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
giorgio70giorgio70 

How can I set the ToAddress in a VisualForce email template?

Hello

 

I created a component/class that returs the email address of the Primary Contact Role for an opportunity.

 

Now I would like to use this value to prepopulate the "TO" address when I chose to use this template.

 

Below is the page I have created.

 

How can use the mail.setToAddresses method?


Thanks

Giorgio

 

 

<messaging:emailTemplate subject="Thanks for your business" recipientType="Contact" relatedToType="Opportunity">
<messaging:plainTextEmailBody >
subject="Test Giorgio Contact Roles"

Congratulations!
This is your new Visualforce Email Template.
Thanks for your donation of

 

mail.setToAddresses(<c:MyEmailComponent componentValue="{!relatedTo.id}" />)

 

</messaging:plainTextEmailBody>

</messaging:emailTemplate>

Thanks