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
motelymotely 

Trigger on Email Template sent to Contact

 

 

One of my marketing users would like a trigger set up for when she sends out a specific email using a template.  Is this possible?  I apologize if this is a repeat question. I tried searching on the topic, but all I found where questions about creating triggers that send email.

 

Here is our basic scenario.  SF User sends an email to a SF contact, inviting them to use our e-commerce site.  When the email is sent, a trigger should fire that assigns a contact role of 'E-Commerce Admin'  to the contact for their account.

 

Does anyone know if I can do that?  Any help would be greatly appreciated.

 

Thanks!

David

 

 

*werewolf**werewolf*

Unfortunately not, or not really anyway -- you could write a trigger on Task (which is what the email will become) but the Task will not retain any memory of what email template it came from.

 

Alternately, you could make a custom button that calls an Apex webservice that sends the email and then stamps the appropriate info on the Contact.  That's not exactly a trigger but it would accomplish the goal.

motelymotely

Thank you for your response.  The user wants the update to happen when she bulk emails contacts rather than a button to send one at a time.

*werewolf**werewolf*

You can equally make your button do a bulk email (or, say, put it on a list view so she can select multiple contacts and email them all).  Regardless, though, the button itself or its underlying Apex will have to run the logic; there's no trigger you can make that will work for this.