0

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
  • 963,270
  • 265
  • 3,804
  • 3,187
Mio K.
  • 1
  • 3

1 Answers1

0

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
  • 188
  • 10