Add Reference to Microsoft Outlook 11.0 Object Library
using System;using System.Reflection;
namespace olAppointments{
public class readAppointments {
public static int Main(string[] args) { try { Outlook.Application objoApp = new Outlook.Application();
Outlook.NameSpace objoNS = objoApp.GetNamespace("mapi");
objoNS.Logon(Missing.Value, Missing.Value, true, true);
Outlook.MAPIFolder objoCalendar = objoNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
Outlook.Items objoItems = objoCalendar.Items; Outlook.AppointmentItem objoAppt = (Outlook.AppointmentItem) objoItems.GetFirst();
Console.WriteLine("Subject: " + objoAppt.Subject); Console.WriteLine("Start: " + objoAppt.Start.ToString()); Console.WriteLine("End: " + objoAppt.End.ToString()); Console.WriteLine("Location: " + objoAppt.Location); Console.WriteLine("Organizer: " + objoAppt.Organizer); Console.WriteLine("Recurring: " + objoAppt.IsRecurring); objoAppt.Display(true);
objoNS.Logoff();
objoAppt = null; objoItems = null; objoCalendar = null; objoNS = null; objoApp = null; }
catch (Exception ex) { Console.WriteLine(ex.Message); }
return 0; } }}
No comments:
Post a Comment