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

后端 未结 2 815
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 05:12

Exchange Web Services has a ResolveNames() function that I can use to retrieve (among other things) the primary SMTP address for the Active Directory user that logged on to

相关标签:
2条回答
  • 2020-12-07 05:53

    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.

    0 讨论(0)
  • 2020-12-07 06:02

    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.

    0 讨论(0)
提交回复
热议问题