1

I get the exchange online addresses from users, but I want to convert or somehow get the SMTP Address of them.

I am not sure how to get the SMTP Address from Email1Address.

Set objOL = CreateObject("Outlook.Application")
Set objNS = objOL.GetNamespace("MAPI")
Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)
Set objItems = objContactsFolder.Items

For Each obj In objItems
    'Test for contact and not distribution list
    If obj.Class = olContact Then
        Set objContact = obj

      With objContact

      If .Email1Address <>"" Then
         'I want to add the SMTP-Address after the .LastNameAndFirstName of a User
          strFileAs = .LastNameAndFirstName

         .Email1DisplayName= strFileAs

         .Save
       End If
      End With
    End If

    Err.Clear
Next
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Mio K.
  • 11
  • 4

1 Answers1

1

I used this for the email object, see if you can implement it:

dim email as string
If myItem.SenderEmailType = "EX" Then
email = myItem.Sender.GetExchangeUser.PrimarySmtpAddress
Else
email = myItem.SenderEmailAdress
End If
donCalculator
  • 318
  • 1
  • 11