I am trying to get at different users inboxes programmatically (see code below). It works fine, except for the fact that the logon line seems to always logon to my local account rather than logging on to other accounts on the network. Anybody know how to logon to other people's accounts using this method?
//Create Outlook application
Outlook.Application oApp = new Outlook.Application();
//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon("user", "password", false, true);
//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems = oInbox.Items;
int intTotalNumberOfItemsInInbox = oItems.Count;
//Get unread e-mail messages
oItems = oItems.Restrict("[Unread] = true");
int intTotalUnread = oItems.Count;
//Create Outlook application
Outlook.Application oApp = new Outlook.Application();
//Get MAPI namespace
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon("user", "password", false, true);
//Get Messages collection of Inbox
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems = oInbox.Items;
int intTotalNumberOfItemsInInbox = oItems.Count;
//Get unread e-mail messages
oItems = oItems.Restrict("[Unread] = true");
int intTotalUnread = oItems.Count;