C#, Sharepoint – Send appointment without using Outlook Object

Two months ago I wrote a small blog about my new project on creating a  SharePoint Webpart for sending appointment. Today a reader asks me how I solve my task at sending appointment without using Outlook Object so I decide to publish my code for sharing with who needs it. In this project I should create a Webpart to send Outlook appointment without using the available Outlook Object. The using of Outlook Object will require that man must install Microsoft Outlook in server and this installation is not worth for supporting only a small Webpart. Therefore in my code I only use classes provided by .Net Framework and do not use any Outlook Object.

using System.Net;
using System.Net.Mail;
using System.Net.Mime;

private void btnSend_Click(object sender, EventArgs e)
//Declaration a list of attendees
MailAddressCollection macCollection = new MailAddressCollection();
//Add attendde. In this example, I send invite to only one
macCollection.Add(new MailAddress("attendee_email"));
//Create mail message
MailMessage mmMessage = CreateMeetingRequest(DateTime.Now.AddHours(1), DateTime.Now.AddHours(2), "Test", "Test", "Test", "yourname", "youremailaddress", macCollection);
//Create smtp client
SmtpClient smtp = new SmtpClient("yoursmtp", 25);
//Configure your smtp client
smtp.EnableSsl = false;
smtp.Credentials = new NetworkCredential("yourloginname", "password");
//Send it

public static MailMessage CreateMeetingRequest(DateTime dtStart, DateTime dtEnd, string strSubject, string strSummary,
string strLocation, string strOrganizerName, string strOrganizerEmail,
MailAddressCollection macAttendeeList)
//Create an instance of mail message
MailMessage mmMessage = new MailMessage();
//  Set up the different mime types contained in the message
System.Net.Mime.ContentType typeText = new System.Net.Mime.ContentType("text/plain");
System.Net.Mime.ContentType typeHTML = new System.Net.Mime.ContentType("text/html");
System.Net.Mime.ContentType typeCalendar = new System.Net.Mime.ContentType("text/calendar");

//  Add parameters to the calendar header
typeCalendar.Parameters.Add("method", "REQUEST");
typeCalendar.Parameters.Add("name", "meeting.ics");

//  Create message body parts in text format
string strBodyText = "Type:Single Meeting\r\nOrganizer: {0}\r\nStart Time:{1}\r\nEnd Time:{2}\r\nTime Zone:{3}\r\nLocation: {4}\r\n\r\n*~*~*~*~*~*~*~*~*~*\r\n\r\n{5}";
strBodyText = string.Format(strBodyText, strOrganizerName, dtStart.ToLongDateString() + " " + dtStart.ToLongTimeString(),
dtEnd.ToLongDateString() + " " + dtEnd.ToLongTimeString(), System.TimeZone.CurrentTimeZone.StandardName,
strLocation, strSummary);
AlternateView viewText = AlternateView.CreateAlternateViewFromString(strBodyText, typeText);

//Create the Body in HTML format
string strBodyHTML = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\r\n<HTML>\r\n<HEAD>\r\n<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=utf-8\">\r\n<META NAME=\"Generator\" CONTENT=\"MS Exchange Server version 6.5.7652.24\">\r\n<TITLE>{0}</TITLE>\r\n</HEAD>\r\n<BODY>\r\n<!-- Converted from text/plain format -->\r\n<P><FONT SIZE=2>Type:Single Meeting<BR>\r\nOrganizer:{1}<BR>\r\nStart Time:{2}<BR>\r\nEnd Time:{3}<BR>\r\nTime Zone:{4}<BR>\r\nLocation:{5}<BR>\r\n<BR>\r\n*~*~*~*~*~*~*~*~*~*<BR>\r\n<BR>\r\n{6}<BR>\r\n</FONT>\r\n</P>\r\n\r\n</BODY>\r\n</HTML>";
strBodyHTML = string.Format(strBodyHTML, strSummary, strOrganizerName, dtStart.ToLongDateString() + " " + dtStart.ToLongTimeString(),
dtEnd.ToLongDateString() + " " + dtEnd.ToLongTimeString(),System.TimeZone.CurrentTimeZone.StandardName,
strLocation, strSummary);
AlternateView viewHTML = AlternateView.CreateAlternateViewFromString(strBodyHTML, typeHTML);

//Create the Body in VCALENDAR format
string strCalDateFormat = "yyyyMMddTHHmmssZ";
strBodyCalendar = string.Format(strBodyCalendar, dtStart.ToUniversalTime().ToString(strCalDateFormat), dtEnd.ToUniversalTime().ToString(strCalDateFormat),
strLocation, strOrganizerName, strOrganizerEmail, Guid.NewGuid().ToString("B"), strSummary, strSubject,
DateTime.Now.ToUniversalTime().ToString(strCalDateFormat), macAttendeeList.ToString());
AlternateView viewCalendar = AlternateView.CreateAlternateViewFromString(strBodyCalendar, typeCalendar);
viewCalendar.TransferEncoding = TransferEncoding.SevenBit;

//Adress the message
mmMessage.From = new MailAddress(strOrganizerEmail);
foreach (MailAddress attendee in macAttendeeList)
mmMessage.Subject = strSubject;

return mmMessage;


  1. I tried with this above code
    its trows Failure Sending Mail
    Please guide me the fix

    Advance Thanks

  2. @Jenkins: Post the complete error message here and I will help you. Maybe your username name,password are wrong or your smtp is wrong. I have no clue to help you until I have an error message from you.

  3. Hi guys,

    I used this example and it works fine, but this code create only a new appointment. I need to modify, to cancel or report an appointment that I created.

    did some one has any solution?


  4. Hi, i believe that this is an outlook meeting request and not an appointment. Is it possible that we generate an appointment and NOT a meeting request?

    Thanks in advance

  5. Terrific article..

    I had issues earlier with Outlook Inter op but this works great in my server farm with no Outlook.

    Thanks for the post and I would really appreciate if you can let me know how do we update an existing meeting request (things such as adding/removing members, editing the description etc)


  6. Thank you for this post.
    But the real challenge of sending a meeting request outside outlook is the changes and updates that will be added later on into the request. As you know 90% of the meeting request will be reschedule and updated, which won’t be possible if you just sent it outside outlook. The only way you will end up sending a new request and asking the users to delete the old request manually.

  7. @Memo: I totally agreed with you. This source code is just a demo for sending appointment without helping from Microsoft Outlook. If you know about how to edit the meeting request later then share it with us. That is always appreciated.

  8. Great Post!!

    To edit the meeting is necessary to save the setting UID nUID:{5}). Outlook detects the UID and searches the database of the calendar if the meeting is that it may modify or cancel, adding the STATUS parameter. To cancel = STATUS: CANCELLED; To Edit only send the same data with the same UID meeting and the meeting will be rescheduled.

  9. Well this code works fine if I use outlook 2007, but when I use Outlook 2003 it does not, can anyone help me to sort out this problem, please.

  10. Jayesh:
    Upgrade to Outlook 2007 atleast man… The latest version is 2010, so basically its been 7 years since that went obsolete.

  11. I searched all around and found this blog, used your code to implement the calendar function, it worked using my SMTP. Thanks a lot to share the technique and I should say you have a great coding practice.

  12. Thanks a lot, really it helped me lot. I need some smaller changes in this
    I want to add ‘more details » Going? Yes – Maybe – No’ instead of ‘Add to calendar »’. Can u please help me?

  13. Hi, I have used this, I have sent the meetings successfully, but out of 15 persons, one received wrong time meeting request. Could you please help me

Leave a comment

Your email address will not be published. Required fields are marked *