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

Visual force Email Template to overwrite / populate the "To" field.

Can I built a VF Email Template where the "To" field can populated or overwritten?


The Email will be sent out from the Lead level, and as you know be default the "To" field displays the Lead Name.


There is a lookup to Contact custom field in the LEAD, and when the VFTemplate is selected the "To" field should be overwritten to that Contact Name which is already selected on the LEAD.


Can this be done?


This is not helpful.


This example is a basic way to create VF Email Template. I get that!


I am asking, how can I overwrite or populate the "TO' section of the Email. ???

I too have this problem.  We need to send emails to Contacts with a template.  The email is sent from an apex trigger.

The problem is that some of the contacts will have an alternate address.  And when a checkbox 'use alternate address' is set, it should email ONLY their alternate address, not the address that is in the standard 'email' field.

I can't figure out a way to override the To address when setting mail.setTargetObjectId(<Contact ID>).

Did you ever figure this out, Sudha76?