You need to sign in to do that
Don't have an account?

Adding Event Invitees through Apex Code
Hi everyone,
I have a tricky situation. I am able to add contacts as event invitees through apex code but an email is not being sent . On the Event record, the contact names are being populated in the " Has'nt Responded " section of the related list. Only if the contact accepts the invitation, his name would come up in the " Accepted " section of the related list . Untill and unless contact gets an email, he/she cannot accept the invitation.
Any help is appreciated. Thanks in advance.
I have a tricky situation. I am able to add contacts as event invitees through apex code but an email is not being sent . On the Event record, the contact names are being populated in the " Has'nt Responded " section of the related list. Only if the contact accepts the invitation, his name would come up in the " Accepted " section of the related list . Untill and unless contact gets an email, he/she cannot accept the invitation.
Any help is appreciated. Thanks in advance.
Thanks
try to create a trigger using this code.. hope this helps.. this code also fixes the problem of sending the email notification to your invitees, so they can accept the events..
trigger autoAddInvitees on Event (after insert) {
//bulkify incomingEvents
List<Event> nEvent = trigger.new;
List<EventRelation> iErelation = new List<Eventrelation>();
//send update to invitees
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.EmailHeader.triggerUserEmail = true;
//loop on bulkfiedEvent
for(Event lEvent : nEvent){
if(lEvent.IsGroupEvent == false){
EventRelation er = new EventRelation();
er.EventId = lEvent.Id;
er.RelationId = '00528000000q1QV';
iErelation.add(er);
}
Database.insert(iErelation, dmo);
}
}
hope that helps.. that fixes the problem of sending an alert to all your invitees
When an event is created, the event relation records are created automatically. The IsInvitee field on the event relation object is set to False during the event relation record creation. This needs to be set as True for the parties (in event relation record) to be considered as invitees. This will ensure the IsGroupEvent field on the corresponding event record to be set as True. This ensures that the event is categorized as multi-party event (an indicator in the UI).
You need to fetch the event relation records (for the corresponding event) and the IsInvitee field needs to be set to True. If we use Database.insert with the DML option, still the email are not getting triggered (i believe its a bug).
Alternate option is to delete the event relation records and insert them using the Database.insert and DML option. The invite email gets triggered only on using Database.insert.