79167480

Date: 2024-11-07 17:24:27
Score: 1
Natty:
Report link

I ended up finding a way to make it work by making a frankencode using some lines from someone who had another problem related to SelectNamesDialog.Display. I am fully aware that the resulting code is very ugly. If someone is kind enough to help me make it pretty, or to explain to me the logical difference between what i originally did ad this code, i would be thrilled.

Private Sub ListeAdresse_Click()

 Dim EmailAddress As String
 Dim myAddrEntry As AddressEntry
 Dim exchUser As Outlook.ExchangeUser
 Dim oDialog As SelectNamesDialog
 Set oDialog = Application.Session.GetSelectNamesDialog
 
 With oDialog
 .InitialAddressList = Application.Session.GetGlobalAddressList
 .ShowOnlyInitialAddressList = True

        If .Display Then

          AliasName = oDialog.Recipients.Item(1).Name

            Set myAddrEntry = Application.Session.GetGlobalAddressList.AddressEntries(AliasName)
            Set exchUser = myAddrEntry.GetExchangeUser

            If Not exchUser Is Nothing Then
               EmailAddress = exchUser.PrimarySmtpAddress

            End If
            CourrielSup.Caption = EmailAddress
   End If
    End With
Set olApp = Nothing
Set oDialog = Nothing
Set oGAL = Nothing
Set myAddrEntry = Nothing
Set exchUser = Nothing

End Sub
Reasons:
  • Blacklisted phrase (1): help me
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Yeti