Setting up an Outlook Appointment through C#
This example shows how to set up an outlook appointment through c#.
First add a reference to the Outlook COM object for your project.
1.In VS.NET right click on References and choose Add Reference.
2.Select the COM tab.
3.Choose "Microsoft Outlook 15.0 Object Library" (this is for MS Office 2013 ) and click Select.
4.Click OK.
using Microsoft.Office.Interop.Outlook;
Microsoft.Office.Interop.Outlook.Application app = null;
app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.AppointmentItem appt = (Microsoft.Office.Interop.Outlook.AppointmentItem)app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
try
{
appt.Subject = "Team Meeting";
appt.Location = "Jupiter Room";
appt.Sensitivity = Microsoft.Office.Interop.Outlook.OlSensitivity.olPrivate;
appt.Start = DateTime.Parse("01/04/2016 02:00 PM");
appt.End = DateTime.Parse("01/04/2016 02:30 PM");
appt.ReminderSet = true;
appt.ReminderMinutesBeforeStart = 10;
appt.Save();
}
catch (System.Runtime.InteropServices.COMException ex)
{
Console.WriteLine(ex.ToString());
}
finally
{
app = null;
appt = null;
}
You can also add sound file for a reminder by setting the ReminderPlaySound property as true.
appt.ReminderPlaySound = true;