I need to be able to search through .pst and .ost files that are stored on a server directory and not part of my default profile. I've used the following code:
Outlook.NameSpace outlookNS = (Outlook.NameSpace)outlookApp.GetNamespace("MAPI");
Outlook.MAPIFolder rootFolder = outlookNS.Stores["test.pst"].GetRootFolder();
foreach (COMObject item in rootFolder.Items)
Outlook.MailItem mailItem = item as Outlook.MailItem;
if (mailItem != null)
There are 3 problems that I'm trying to address:
- This uses the default profile on my computer. I'd prefer not to do this. Is there a way to create a temporary profile?
- The line "Outlook.MAPIFolder rootFolder = outlookNS.Stores["test.pst"].GetRootFolder();" throws an exception. I can get around this by referring to the store by its ordinal number but that is a little messy. How do I properly refer to
the store I've just added?
- There is no apparent Namespace.RemoveStore() method in the NetOffice API. How do I remove a store once I'm done with it?
Thanks in advance for any help.