问题
Firstly , I am a freshmen to outlook add-in development,Recently I read some learning material from MSDN or other tutorial, The First thing makes me confused is if I want to find something like a certain Appointment or Meeting Request from inbox, I should firstly use Application.GetNameSpace(“MAPI”)
to get a NameSpace
instead of getting some kind of object like Folder
or Appointment
Collections and so on.
I don't understand the Data Store Access pattern of Outlook 2007 in Add-in development. I hope someone can help me better understand Data store access of outlook 2007.
回答1:
A MAPI Session is required to interact with an Outlook Data Store. Application.Session is interchangeable with Application.GetNamespace("MAPI")
. You can think of a session as a connection to the Outlook Data Store.
To retrieve appointments, you can use Namespace.GetDefaultFolder.
Outlook.Folder appointmentStore = Globals.ThisAddIn.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar) as Outlook.Folder;
string apptSubject = string.Empty;
foreach (Outlook.AppointmentItem appt in appointments.Items.OfType<Outlook.AppointmentItem>())
apptSubject = appt.Subject;
来源:https://stackoverflow.com/questions/11956345/how-to-understand-namespace-of-outlook-2007-data-store