Is there a way to trigger the "Save and Send Update" button's functionality with Apex? I want to send the same email message for the invitees on an Event trigger.
I tried something as follows but nothing happens,
public class sendSaveUpdateMail implements Triggers.Handler {
public void run(){
if(!(Trigger.isAfter && Trigger.isUpdate)) return;
if (IS_TRIGGER_RAN) { // static variable to keep track on trigger recursive run
return;
} else {
IS_TRIGGER_RAN = true;
}
Set<Id> erids = new Set<Id>();
List<Event> events = new List<Event>();
for (Event e : (List<Event>)trigger.new){
erids.add(e.id);
}
List<EventRelation> eventRelations = [SELECT Id, RelationId From EventRelation where eventid IN:erids];
Database.DMLOptions dlo = new Database.DMLOptions();
dlo.EmailHeader.triggerUserEmail = true;
Database.update(eventRelations,dlo);
}
}
Thanks in advance.