0

As per Microsoft mailItem.Recipients[i].Address returns something like the below:

/O=MFC2013/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=B370134F8FFD4CF3A0023F27B6B61F7D-ADMINISTRATOR

What are those values and how and where are they configured?

braX
  • 11,506
  • 5
  • 20
  • 33
user1226058
  • 403
  • 1
  • 6
  • 12
  • 2
    Does this answer your question? [How do you extract email addresses from the 'To' field in outlook?](https://stackoverflow.com/questions/12641704/how-do-you-extract-email-addresses-from-the-to-field-in-outlook) – niton Apr 22 '20 at 13:18

1 Answers1

0

Microsoft Exchange Server can operate with email address types such as Exchange, SMTP, X.400, Microsoft Mail, etc. By default, the Address property of the Mail.Recipient object returns just an Exchange type address, for example, this one:

/O=MFC2013/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=B370134F8FFD4CF3A0023F27B6B61F7D-ADMINISTRATOR

To retrieve the SMTP address, use the following sequence of calls:

Recipient.AddressEntry.GetExchangeUser().PrimarySmtpAddress

Theoretically, to get other address types, we need to find the recipient in the Outlook address book by using the IAddrBook.ResolveName method, then reach the IMailUser interface with the IAddrBook.OpenEntry method and get the PR_EMS_AB_PROXY_ADDRESSES property.

Function ResolveDisplayNameToSMTP(sFromName)
  Dim oRecip As Outlook.Recipient
  Dim oEU As Outlook.ExchangeUser
  Dim oEDL As Outlook.ExchangeDistributionList

  Set oRecip = Application.Session.CreateRecipient(sFromName)
  oRecip.Resolve
  If oRecip.Resolved Then
    Select Case oRecip.AddressEntry.AddressEntryUserType
      Case OlAddressEntryUserType.olExchangeUserAddressEntry
        Set oEU = oRecip.AddressEntry.GetExchangeUser
        If Not (oEU Is Nothing) Then
          ResolveDisplayNameToSMTP = oEU.PrimarySmtpAddress + vbCrLf + oEU.BusinessTelephoneNumber
        End If
      Case OlAddressEntryUserType.olOutlookContactAddressEntry
        Set oEU = oRecip.AddressEntry.GetExchangeUser
        If Not (oEU Is Nothing) Then
          ResolveDisplayNameToSMTP = oEU.PrimarySmtpAddress + vbCrLf + oEU.BusinessTelephoneNumber
        End If
      Case OlAddressEntryUserType.olExchangeDistributionListAddressEntry
        Set oEDL = oRecip.AddressEntry.GetExchangeDistributionList
        If Not (oEDL Is Nothing) Then
          ResolveDisplayNameToSMTP = oEU.PrimarySmtpAddress + vbCrLf + oEU.BusinessTelephoneNumber
        End If
    End Select
  End If
End Function  ' ResolveDisplayNameToSMTP
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45