Is it possible to add invitees automatically when a Calendar Event is created? The requirement is to automatically create invitees based on a custom Event Field (Contract Value). The List of Invitees are maintained in a custom Object (Fields: Min Contract Value, Max Contract Value, Invitee Email etc..).

Depending on the data value entered in the Custom Field (Contract Value) the Invitee(s) should be automatically created.

1 Answer 1


Its certainly possible to do what you're speaking of. Are the data values a simple look-up to the contacts? If so, I'd think you could do this through workflow rather than using a trigger.

However, If determining who the invitees are involves a query or using more sophisticated logic, then an "after insert" on Event trigger which sends emails to the list of invitees would seem more appropriate for your purpose.

Edited to add

Even if on the Force.com platform using Salesforce for Outlook, I can't tell you how to access a user's calendar. However, you could still implement a trigger that could email an invitation to users, so they could add the event to their calendars. I believe you'd want to create a template for that purpose so it was clear it was an event invitation.

The code would look something like this:

// This is for a SINGLE email to all recipients in your list

// From your query results, assembled string that holds the email
// addresses to which you are sending the email.
String[] toAddresses = new String[] {'[email protected]'}; 
String[] ccAddresses = new String[] {'[email protected]'};

// First, reserve email capacity using size() of query results list
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(queryresults.size());

// Now create a new single email message object
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

// Assign the addresses for the To and CC lists to the mail object.

// Specify the address used when the recipients reply to the email. 
mail.setReplyTo('[email protected]');

// Specify the name used as the display name.
mail.setSenderDisplayName('Event Organizer');

// Specify the subject line for your email address.
mail.setSubject('New Event Created : '+ Event.Name +' '+ Event.Id);

// Set to True if you want to BCC yourself on the email.

// Optionally append the email signature to the email.
// If true, email address of user executing Apex Code is used.

// Specify the text content of the email.
mail.setPlainTextBody('You're invited to a new event: ' + Event.Name + ' ' + Event.Id);

// Optionally, you can specify the HTML template you want to use
mail.setTemplateId(value ForId of Event Template);  

// Specify the HTML content of the email.
mail.setHtmlBody('You\'re invited to a new event:<b> ' + Event.Name + ' ' + Event.Id + ' </b><p> 'To view the details <a href=https://(your salesesforce na1 instance or URI /'+event.Id+'>click here.</a>');

// Send the email you have created.
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

It would seem to me that with the right template, the people in your org would be able to use the email as either a meeting invitation which they can calendar or else as a link to an event they can then add to their calendar. I know nothing of how Outlook for Salesforce works to give you any idea of how to link into their API to do anything other than this.

  • Thanks for the response, We are on Force.com and the recipients are maintained in a custom object (with Fields lik Min Contract Value, Max Contract Value, Email etc). Depending on the data value entered in the Custom Event Field (Contract Value) the Invitee(s) should be automatically created and their Outlook synced with event details(which is straightforward via Salesforce for outlook). I believe Trigger on Event Object should be the right choice but which Object represents the Invitees and how do I insert the retrieved list (mandatory Fields etc)?
    – KaLi
    Apr 16, 2013 at 2:38
  • After further investigation found that this feature cannot be achieved programmatically. Response from Salesforce: Please be informed that "Adding Invitees automatically to a Calendar Event" is currently not a functionality that Salesforce has. Given the fact I am now looking for any viable workaround, pls suggest if you have any.
    – KaLi
    Apr 16, 2013 at 6:04
  • thanks indeed for the response ...it helps to send invites via an email; however my requirement is slightly different, unless you add invitees manually into the Invitees list while creating an event the same will not get synced with the invitees Outlook (via Salesforce for Outlook). -- For now decided to add the invitees manually and hope the programmatic access to EventAttendees Object will be part of next release --
    – KaLi
    Apr 17, 2013 at 17:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .