Reputation: 77
I am trying to login to a mailbox using the following code, but it logs in to my local outlook mailbox instead of the one specified in the code in oNS.Logon("account", "password", false, false)
line. Do I need to use Redemption.RDOSession
for the same ? If so, how to use it in C#?
oApp = new Outlook.Application();
oNS = oApp.GetNamespace("mapi");
oNS.Logon("account", "password", false, false);
var EntryID = oApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).EntryID;
var StoreID = oApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox).StoreID;
var folderID = oNS.GetFolderFromID(EntryID, StoreID);
When I use RDSession.LogonHostedExchangeMailbox
, the error I am getting is as follows:
GetAutodiscoverForEmailAddress: There are no autodiscover servers in the AD for this address Error in WinHttpSendRequest(collabera.com/autodiscover/autodiscover.xml): ERROR_WINHTTP_TIMEOUT Error in WinHttpSendRequest(collaberainc.mail.onmicrosoft.com/autodiscover/autodiscover.xml): ERROR_WINHTTP_NAME_NOT_RESOLVED Error in WinHttpSendRequest(autodiscover.collaberainc.mail.onmicrosoft.com/autodiscover/autodiscover.xml): ERROR_WINHTTP_CANNOT_CONNECT HTTP error 401 from https://autodiscover-s.outlook.com/autodiscover/autodiscover.xml Server response:
GetAutodiscoverUrlFromDns error: DNS lookup error using 172.17.18.50:DNS Server Reports Query Name Error DNS lookup error using 172.30.30.53:DNS Server Reports Query Name Error DNS lookup error using 172.30.30.11:DNS Server Reports Query Name Error Expected HTTP_STATUS_REDIRECT, received 403 Could not retrieve any autodiscover URLs from DNS lookup
Upvotes: 1
Views: 400
Reputation: 66245
Namespace.Logon
in OOM takes the name of an existing profile (as shown in Control Panel | Mail | Show Profiles), not the name of a mailbox.
Since you tagged your question "Outlook-Redemption", I assume you are looking for a Redemption solution. In that case, use RDOSession.LogonHostedExchangeMailbox
- it indeed takes an SMTP address of an Exchange mailbox, configures a temporary profile, logs in, and deletes the profile.
Upvotes: 2