• Fermin Campo 1
  • 0 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1
Since you can not use workflows to send an email update on a Event, I am working on creating a trigger that will send email.  I created an email template called MCC_Close_Event_Email and based it on the Event object.  I tested it and made sure it pulls all the correct info when sending.  

Then I created the trigger below to send the email when a cretain field is checked.  
trigger EventSendEmailMCCReminder on Event (After Update, After Insert) {

/*  Event e1 = trigger.new[0];  */
    For (Event e1 : trigger.New){
  String[] toAddresses = new String[] {e1.owner.email};
  String[] strProfile = New String[] {e1.owner.profile.name};    
  Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

  mail.setSenderDisplayName('Salesforce Admin');
  System.debug('Profile Name ' + e1.owner.profile.name);
  System.debug('Owner Name ' + e1.owner.name);  
  System.debug('Profile Name ' + strProfile);
  System.debug('To Address ' + toAddresses);        
	If(e1.SendMCCRemiderEmail__c == True ){
 /*       If(e1.owner.profile.name == 'System Administrator'){ */
		EmailTemplate et=[Select id from EmailTemplate where DeveloperName=:'MCC_Close_Event_Email'];
        Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});         
My issue is, it send the email, but all the Event related fields in the email are blank.  Also, all me System.Debug values are blank in the debug log.  

Any ideas to ensure the Event related fields in the Email are populated?