Retrieve Outlook logged-in user SMTP address after connecting through OLE

非 Y 不嫁゛ 提交于 2019-11-28 02:22:34

Why not use Application.Session.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress (you would of course need to check for nulls)?

As for the account order, you can either use Extended MAPI and IOlkAccountManager.GetOrder (you can play with that object in OutlookSpy if you click IOlkAccountManager button) or you can use Redemption and its RDOSession.Accounts.GetOrder method (see http://www.dimastr.com/redemption/RDOAccounts.htm). The first account in the returned collection will be the default one.

Jan Doggen

I found it. I have to go through the Accounts object in the namespace:

for i := 1 to lNameSpace.Accounts.Count do
   if lNameSpace.Accounts.Item[i].AccountType = olExchange then
   begin
      lAccount := lNameSpace.Accounts.Item[i];
      Break;
   end;
if VarIsClear(lAccount) then
begin
   DisConnectFromOutlook;
   Exit;
end;
lLoginSMTP := lAccount.SmtpAddress;

The only thing I would still like is to determine the default account.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!