Difference between Outlook.Folder and Outlok.MAPIFolder

I do not understand the difference between the Folder and MAPIFolder in the Outlook namespace. When I browse the code on the net, some use the first, while others use a different syntax, and I cannot 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 (use for different versions of Outlook)
  • This is the same (something I'm sure is wrong, but no one knows)
  • it's an inheritance structure (and what to use when)
  • it's just a way to avoid type problems (casting and as -ing)
  • this is another reason (s) completely (and if so, which ones)

Here is the code I use to get these 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); 
+6
source share
1 answer

Folder replaced MAPIFolder , which is now deprecated . See related SO post . Folder contains additional event hooks compared to MAPIFolder

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

MAPIFolder and GetNamespace() are migrated from Outlook 2003 and below - they have just been saved for backward compatibility. There is no way to avoid casting with VSTO - you will be constantly boxed and unpacked.

+13
source

Source: https://habr.com/ru/post/924996/


All Articles