I have a code sample as below:
Database.DMLOptions dmlo = new Database.DMLOptions();
dmlo.EmailHeader.triggerUserEmail = true;
database.insert( this.myNewEventsWithEmail, dmlo );
system.debug('@@ Create Events (With EMAIL) : ['+myNewEventsWithEmail.size() + '] ( '+dmlo+' )');
where this.myNewEventsWithEmail
is list of Event sObjects.
My debug log says that this code was executed and with correct EmailHeader option:
02:49:32.033 (1033993374)|USER_DEBUG|[430]|DEBUG|@@ Create Events (With EMAIL) : [2] ( DMLOptions:[AllowFieldTruncation=null, AssignmentRuleHeader=AssignmentRuleHeader:[AssignmentRuleId=null, UseDefaultRule=null], DuplicateRuleHeader=DuplicateRuleHeader:[AllowSave=null], EmailHeader=EmailHeader:[TriggerAutoResponseEmail=null, TriggerOtherEmail=null, TriggerUserEmail=true], LocaleOptions=null, LocalizeErrors=null, OptAllOrNone=null] )
I have verified that triggerUserEmail
is set to True
but still No Email is being sent
to the user who is assigned the Event.
Weird thing is, same code works just fine with list of Task object records.