MAPIFolder deprecated so workaround for Outlook programming?

痴心易碎 提交于 2020-01-03 21:09:50

问题


MSDN says this of the MAPIFolder interface (Outlook programming with WPF):

This interface is deprecated; do not use this interface. Instead use the interface Folder to access all method, property, and event members of the COM object Folder.

I am trying to get the Drafts folder like so:

Outlook.MAPIFolder oFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts);

How do I do the above without using the MAPIFolder (which is deprecated)? I guess I don't understand what MSDN is saying (using the Folder interface to access all method etc)


回答1:


You simply cast it to Outlook.Folder, i.e.

Outlook.Folder oFolder = (Outlook.Folder) olNS.GetDefaultFolder( Outlook.OlDefaultFolders.olFoderDrafts)

Admittedly, the MSDN is rather unclear there. You can think of the Folder interface as a wrapper around the MAPIFolder, with additional support for events.

As I sidenote, I would take the whole 'deprecated' thing with a grain of salt. I'd bet MAPIFolder is here to stay, at least for a couple more versions of Outlook.



来源:https://stackoverflow.com/questions/6213749/mapifolder-deprecated-so-workaround-for-outlook-programming

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