public DataTable GetCalenderDetails()
{
DataTable table = new DataTable();
table.Columns.Add("Subject", typeof(string));
table.Columns.Add("Datetime", typeof(DateTime));
table.Columns.Add("Location", typeof(string));
table.Columns.Add("Organizer", typeof(string));
Microsoft.Office.Interop.Outlook.Application oApp = null;
Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;
Microsoft.Office.Interop.Outlook.MAPIFolder calendarFolder = null;
try
{
oApp = new Microsoft.Office.Interop.Outlook.Application();
mapiNamespace = oApp.GetNamespace("MAPI");
calendarFolder = mapiNamespace.GetDefaultFolder
(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
DataRow dr;
foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in
calendarFolder.Items)
{
dr = table.NewRow();
dr["Location"] = item.Location;
dr["Subject"] = item.Subject;
dr["Datetime"] = item.Start;
dr["Organizer"] = item.Organizer;
table.Rows.Add(dr);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return table;
}