In last article, I showed how to create Global Calendar WebPart
Continue for this solution, I would like to introduce how to deliver Meeting Request from Calendar. So that, all event in calendar will be showed in Google Calendar or Outlook calendar as well.

Functional requirements in brief:
–          Scheduling: Instant meeting management, send invitation, automated notifications and attendee confirmations (using outlook notification or google calendar notification).

SharePoint Calendar

Outlook Calendar

Firstly, I will declare a class named MeetingRequest with some function for SMTP functional

class MeetingRequest
{

//Get the site ID

public static string GetSMTPHostName(Guid siteID)
{
using (SPSite site = new SPSite(siteID))

{

//Get the SMTP host name from “Outgoing e-mail settings”

return site.WebApplication.OutboundMailServiceInstance.Parent.Name;

}

}
//Get Outgoing email server settings
public static string GetFromEmailID(Guid siteID)
{

using (SPSite site = new SPSite(siteID))

{

//Get the “from email address” from “Outgoing e-mail settings”

return site.WebApplication.OutboundMailSenderAddress;

}

}
//Send Meeting Request with

public static void SendMeetingRequest(SPWeb web, string listName, int itemID, string organizerEmail, List<string> toEmailList, string title, string body)

{

Guid siteID = web.Site.ID;

iCal ical = new iCal();

string icalData = ical.GetICSFormat(web, listName, itemID, organizerEmail);

MailMessage msg = new MailMessage();

msg.From = new MailAddress(organizerEmail);

if (toEmailList.Count > 0)

{

for (int i = 0; i < toEmailList.Count; i++)

{

msg.To.Add(toEmailList[i]);

}

}

msg.Subject = title;

msg.Body = body;

AlternateView htmlView = AlternateView.CreateAlternateViewFromString(body, new ContentType(“text/html; method=request; charset=UTF-8;component=vevent”));

System.Net.Mime.ContentType ct = new System.Net.Mime.ContentType(“text/calendar”);

ct.Parameters.Add(“method”, “REQUEST”);

AlternateView avCal = AlternateView.CreateAlternateViewFromString(icalData, ct);

msg.AlternateViews.Add(avCal);

msg.AlternateViews.Add(htmlView);

SmtpClient clt = new SmtpClient(GetSMTPHostName(siteID));

try

{

clt.Send(msg);

}

catch { }

}

}

As you see, I build a class named iCal, actually I will generate an ICS file format depend on type of Request is normal request, all day request or recurrence request. You can find this class in attachment in this article.

Important Note: SendMeetingRequest method will get SMTP outgoing mail server name. So your SharePoint server must be configured for outgoing mail server. To implement this, you can check:
For SharePoint 2007: http://technet.microsoft.com/en-us/library/cc263462%28office.12%29.aspx#section2
For SharePoint 2010
http://technet.microsoft.com/en-us/library/cc288949.aspx#section5

Hoang Nhut NGUYEN
Email: nhutcmos@gmail.com
Skype: hoangnhut.nguyen