How to understand Namespace of outlook 2007 data store

我们两清 提交于 2020-01-14 19:50:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!