Sharepoint - How can I get a Sharepoint calendar to send a notification email to users involved in an event?

Here is my implementation of Vedran's answer:

First, in a feature receiver, I swapped the Event content type with the Schedule content type to take advantage of the Attendees field (and the cool Free/Busy field!):

SPList list = lists["Calendar"];
SPContentType newContentType = 
    list.ContentTypes.Add(list.ParentWeb.ContentTypes[SPBuiltInContentTypeId.Schedule]);
SPContentType oldContentType = list.ContentTypes[0];
string name = oldContentType.Name;
string description = oldContentType.Description;
oldContentType.Delete();
newContentType.Name = name;
newContentType.Description = description;
newContentType.Update();

The form now looks like this:

enter image description here

Second, I added an Event Receiver that sends the notices:

public override void ItemAdded(SPItemEventProperties properties)
{
    SPList list = properties.List;
    SPListItem item = properties.ListItem;
    SPFieldUserValueCollection values = item[SPBuiltInFieldId.ParticipantsPicker] as SPFieldUserValueCollection;

    List<string> emails = new List<string>();
    foreach (SPFieldUserValue value in values)
    {
        SPUser user = value.User;
        if (!string.IsNullOrEmpty(user.Email))
        {
            emails.Add(user.Email);
        }
    }

    if (emails.Count > 0)
    {
        StringDictionary headers = new StringDictionary();
        headers.Add("to", string.Join(";", emails.ToArray()));
        headers.Add("subject", item.Title);
        SPUtility.SendEmail(web, headers, body);
    }
}

It works great.


You could create a column for the calendar that is "attendees" that is a people or group type column. Then you can create a very simple workflow that will send an email to those people who are entered. This could be done with SharePoint Designer.


One of solutions is to add new people type column (or use OOTB Attendees column) to calendar for storing meeting attendees.

Then you can write custom event receiver for calendar list that handles email notification(s) according to meeting changes (attendee added, deleted, meeting canceled etc.). This approach is not simple but has some benefits (you can easily redeploy solution to affect other calendars).

I need to point out that SharePoint calendar doesn't provide OOTB function to easily receive auto meeting responses (like eg Exchange). This makes most of the new SharePoint users quite unhappy.

Tags:

Email

Calendar