简体   繁体   中英

Retrieving Mails/Attachements from Exchange Server

I am trying to connect with a mailbox on our exchange server, and I have the servername, username and password.

At the moment I have the following code to connect to my personal mailbox and this is working fine:-

            app = new Application();
            ns = app.GetNamespace("MAPI");

            Helpers.AddToErrorLog("CESTOAD mailbox", DateTime.Now.ToString(), "Logging into CESTOAD mailbox");
            ns.Logon(user, password, false, false);


            inboxFolder = ns.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
            subFolder = inboxFolder.Folders["ComDocsAttachements"];

However, I cannot find out how to connect to another account with a username and password on the same exchange server. When I change the user and password in the Logon, it still retreives my account.

Can anyone point me in the right direction?

Not sure what library, or API you are using to connect to Exchange, but I would guess that the logon call is still detecting your initial logon, and regarding you as authenticated, and not trying to log you on with the new credentials. Is there a Logoff method you could call first?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM