I am having a little trouble sending an email to a lead using a template when an Event of type visit is created and again the day before the event. I can't use a workflow because ActivityDate is not available to be referenced. Also not sure how the lead's email will be determined when sending the email. I would like an example of workflow to do this. Or perhaps Is there a a good way to go about this? Maybe a trigger. But the setTargetId of Messaging.SingleEmailMessage does not seem to support event. Any suggestion on how I should approach this? Examples would be great.


    <messaging:emailTemplate subject="Hello" recipientType="Lead" relatedToType="Event">
    <messaging:htmlEmailBody >
      <p>This is a reminder about your visit on <strong>{!relatedTo.ActivityDate}</strong></p> 
      <p>Please use the details below as a reminder of your visit </p> 
      <p><strong>Location:</strong> {!relatedTo.Location} </p>  
     <p>{!relatedTo.Owner.Name} </p>

1 Answer 1


You can use setTargetObjectId to the contact and setWhatId to the event in the trigger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.