本文介绍了Outlook.Folder和Outlok.MAPIFolder的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是在命名空间<$ C $类文件夹 MAPIFolder 之间的差别清晰C>展望。当我回顾在网上的代码,一些使用第一个,而其他人使用其他的语法和我真的不能确定:




  • 这只是因为他们的无知(甚至更少,我可以告诉哪一组是正确的)

  • 这是一些传统的(使用了不同版本的Outlook)

  • 这是同样的事情(这是我相当肯定是不正确的,但谁也不知道)

  • 这是一个继承结构(以及何时使用什么)

  • 它只是避免类型问题(铸造及 -ing)

  • 的方式
  • 这是其他原因(S)全部(如果有的话,它)



下面是我使用获得这两个代码。

  Outlook.Folder defaultContactsFolder_1 = 
this.Application.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderContacts)作为Outlook.Folder;

Outlook.MAPIFolder defaultContactFolder_2 =
this.Application.GetNamespace(MAPI)GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderContacts)。


解决方案

的已取代的。看到这么帖子相关还有其他事件挂钩相比, MAPIFolder



Application.Session ==作为应用.GetNamespace(MAPI) - 他们是可以互换的。看到这么帖子相关从Outlook 2003中随身携带接管及以下 - 他们刚刚被保持向后兼容性。有没有办法避免VSTO型铸造 - 你会不断地装箱和拆箱


I'm not clear on the difference between the classes Folder and MAPIFolder in the namespace Outlook. When I review the code in the net, some use the first, while others use the other syntax and I can't really determine if:

  • it's just because of their ignorance (and even less I can tell which group is the right one)
  • it's some kind of legacy (usage for different versions of Outlook)
  • it's the very same thing (something I'm fairly sure isn't true but one never knows)
  • it's an inheritance structure (and what to use when)
  • it's simply a way to avoid type issues (casting and as-ing)
  • it's other reason(s) entirely (and if so, which)

Here's the code I'm using for obtaining those two.

Outlook.Folder defaultContactsFolder_1 =
  this.Application.Session.GetDefaultFolder(
    Outlook.OlDefaultFolders.olFolderContacts) as Outlook.Folder;

Outlook.MAPIFolder defaultContactFolder_2 =
  this.Application.GetNamespace("MAPI").GetDefaultFolder(
    Outlook.OlDefaultFolders.olFolderContacts);
解决方案

Folder has superseded MAPIFolder which is now deprecated. See related SO post. Folder has additional event hooks as compared to MAPIFolder

Application.Session == Application.GetNamespace("MAPI") - they are interchangeable. See related SO post.

MAPIFolder and GetNamespace() are carry overs from Outlook 2003 and below - they've just been kept for backwards compatibility. There's no way to avoid type casting with VSTO - you will constantly be boxing and unboxing.

这篇关于Outlook.Folder和Outlok.MAPIFolder的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-06 13:40