I'm trying to pull Outlook store information from the non-default profile. The solution here does essentially what I want, except it only pulls from the default profile. According to MS documentation, I should be able to specify the profile with the NameSpace.Logon method. But no matter what I specify with NameSpace.Logon, I only get stores from the default profile.
For example, this code just outputs the default profile ("Outlook"), not the "archive" profile:
using Microsoft.Office.Interop.Outlook;
...
Application objApp = null;
NameSpace ns = null;
objApp = new Application();
ns = objApp.GetNamespace("MAPI");
ns.Logon("archive");
Console.WriteLine(ns.Session.CurrentProfileName);
I've also tried using the Logon method with the Application.Session object, rather than the Application.Namespace object, but I get the same result.
Make sure that no
outlook.exeprocesses exist in the list of running processes. Outlook is a singleton, if any instance has not been closed and still running on the system, you will not be able to logon to another profile and continue dealing with the current session/profile.