Diferent ways to get the namespace

Add-in Express™ Support Service
That's what is more important than anything else

Diferent ways to get the namespace
Exists a correct mode to get the Outlook.NameSpace 
Desenvolvimento F?cil


Guest


Hey guys,

I'm developing an AddIn for Outlook and I have a question about the correct mode to get the Outlook.NameSpace.

In my code I usually need to get the Outlook.NameSpace and I've been doing this in 2 differents ways.

1)
 
Outlook.NameSpace ns = OutlookApp.GetNamespace("MAPI");//OutlookApp is the Outlook._Application

2)

Outlook.NameSpace ns = OutlookApp.Session;//OutlookApp is the Outlook._Application


what is the best way? Can you tell me why?

Thanks,
Rissardi.
Posted 27 Aug, 2015 15:03:23 Top
Dmitry Kostochko


Add-in Express team


Posts: 2887
Joined: 2004-04-05
Hi Rissardi,

Please have a look at the description of both ways.

https://msdn.microsoft.com/en-us/library/office/ff865800.aspx
Remarks
The GetNameSpace method is functionally equivalent to the Session property.

https://msdn.microsoft.com/EN-US/library/office/ff866436.aspx
Remarks
The Session property and the GetNamespace method can be used interchangeably to obtain the NameSpace object for the current session. Both members serve the same purpose.

So, you can use either way.
Posted 28 Aug, 2015 05:03:17 Top