Activity Forums Salesforce® Discussions How to send Visualforce Email using a template from a Salesforce Trigger?

  • Gourav

    Member
    May 25, 2016 at 12:55 pm

    In order to use VF Email templates, you have to send an email to a Lead, Contact, or User via setTargetObjectId with the associated merge fields.

    I don't believe you can freeform an email address.

    Also be aware sending single emails you max out at 10 emails per request, so you'll have to make sure that your trigger doesn't send anymore than 10 emails.

    If it does, you'll need to use 'Bulk email' which doesn't allow templates either.

  • Avnish Yadav

    Member
    September 30, 2018 at 3:36 am

    Hello,

    1. First, create a Visualforce email template:Click Setup | Email | My Templates. If you have permission to edit public templates, click Setup | Communication Templates | Email Templates.
    2. Click New Template.
    3. Choose Visualforce and click Next.
    4. Choose a folder in which to store the template.
    5. Select the Available For Use checkbox if you would like this template offered to users when sending an email.
    6. Enter an Email Template Name.
    7. If necessary, change the Template Unique Label.
    8. Select an Encoding setting to determine the character set for the template.
    9. Enter a Description of the template. Both template name and description are for your internal use only.
    10. Enter the subject line for your template in Email Subject.
    11. In the Recipient Type drop-down list, select the type of recipient that will receive the email template.
    12. Optionally, in the Related To Type drop-down list, select the object from which the template will retrieve merge field data.
    13. Click Save.
    14. Click Edit Template.
    15. Enter markup text for your Visualforce email template.
    16. Click Save to save your changes and view the details of the template, or click Quick Save to save your changes and continue editing your template. Your Visualforce markup must be valid before you can save your template.

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos