Thursday, February 19, 2009

Create Outlook appointment or meeting request using C#.NET

Create an appointment or meeting request using C#. You need the Microsoft Office framework.

using Microsoft.Office.Interop.Outlook;

public static void CreateMeetingRequest(string to, string subject, string body, DateTime startDate , DateTime endDate)
{
Microsoft.Office.Interop.Outlook.Application objOL = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.AppointmentItem objAppt = (Microsoft.Office.Interop.Outlook.AppointmentItem)objOL.CreateItem(OlItemType.olAppointmentItem);
objAppt.Start = startDate;
objAppt.End = endDate;
objAppt.Subject = subject;
objAppt.Body = body;
objAppt.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting;
objAppt.RequiredAttendees = to;
objAppt.Send();
objAppt = null;
objOL = null;
}

private void button1_Click(object sender, System.EventArgs e)
{
CreateMeetingRequest("xxx@xxx.com", "test", "try email", Convert.ToDateTime("02/19/2009 11:55"), Convert.ToDateTime("02/20/2009 11:55"));
}

http://www.systemnetmail.com/

http://www.officewiki.org/default.aspx/Outlook.AppointmentItem

http://www.outlookcode.com/d/index.htm

Advanced calendaring with Exchange 2000

http://msdn2.microsoft.com/en-us/library/ms991812.aspx