How to connect to a specific Outlook / Exchange account?

I am building an application to access a specific email account hosted on an Exchange 2003 server and doing some things for unread messages found. I don’t know much about how MAPI works, so I wouldn’t be too surprised if I missed something very obvious! I (unfortunately) using C #, I read about the problems that may arise (and I'm afraid of the consequences, but my boss wants it to be done this way ...).

I am struggling to find good information on how to connect to a specific account! The application will be launched from some laptop (say mine), so there will be a default account with which Outlook connects when opened. So:

  • Is it possible to connect to another account from a computer on which the user already has his own account and, possibly, Outlook is open?

  • If possible. How should I do it? When starting Outlook interaction objects, the application automatically receives a user account and sets the current user for this. I was hoping the method would Logon()sort this out, but no. It even just works.    Outlook.Application olApp = new Outlook.Application(); Goes and sets the current user to a standard account.

I hope I have a point (maybe not), but feel free to ask more detailed questions in the comments and I will answer as quickly as possible. As I said, I know very little about MAPI and Exchange, so I struggle with how to formulate my question.

+5
source share
3

Exchange 2003, WebDAV, CDOEX, ExOLEDB. Exchange 2007+, EWS.

Outlook Interop ( ). - .

+4

Redemption - , , RDOSession. LogonExchangeMailbox , , RDOSession. GetSharedMailbox/GetSharedDefaultFolder.

Exchange 2013 RPC ( RPC-over-HTTP MAPI-over-HTTP), RDOSession.LogonHostedExchangeMailbox ( Exchange 2013, Exchange 2010).

+1

, , :

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

// optional
//object missing = Type.Missing;
//ns.Logon(missing, missing, true, false);

// additional email address 
string recipientName = "myEmail@myDomain";

Outlook.Recipient recip = ns.CreateRecipient(recipientName);
recip.Resolve();

if (recip.Resolved)
{
Outlook.MAPIFolder inboxFolder = ns.GetSharedDefaultFolder(recip, Outlook.OlDefaultFolders.olFolderInbox);
}
+1

All Articles