Im writing a Service-Application that should monitor one or more ExchangeMailboxes for incoming Mails to perform some action with those.
The Service will run in different environments, which means i need to support Outlook 2010 to 2019.
How can i reliably Logon to a Session from a Service-Application no matter the Outlookversion?
I have the following code that works for Outlook 2010 but not 2016. The ExchangeServer is the same and using version 2010.
for MailboxName in MailboxesToMonitor do
begin
Session := RedemptionLoader.new_RDOSession;
Session.LogonExchangeMailbox(MailboxName, 'ExchangeServerName'); // works for 2010, but not 2016
DefaultStore := Session .Stores.DefaultStore;
if (LDefaultStore.StoreKind in [skPrimaryExchangeMailbox, skDelegateExchangeMailbox]) then
begin
MailboxStore := TRDOExchangeMailBoxStore.Create(Self);
try
MailboxStore.ConnectTo(DefaultStore as IRDOExchangeMailboxStore);
MailboxStore.OnNewMail := RDOStoreOnNewMail;
except
LMailboxStore.Free;
raise;
end;
Sessions.Add(Session);
end;
end;
Session.LogonExchangeMailbox
throws a MAPI_E_UNKNOWN_FLAGS error with Outlook 2016 installed.Session.Logon
didnt work in a ServiceApplication.Session.LogonHostedExchangeMailbox
throws:- EOleSysError: Expected HTTP_STATUS_REDIRECT, recieved 403
- EIdDnsResolverError: DNS Server Reports Query Name Error
- EHTTPError: HTTP error 401 from
https://autodiscover.domain.com/autodiscover/autodiscover.xml
- EOleSysError: GetAutodiscoverUrlFromDns error: DNS lookup error using xx.xx.xx.xx: DNS Server Reports Query Name Error
- EOleSysError: GetAutodiscoverForEmailAddress: There are no autodiscover servers in the AD for this address