By using vba.booksticle.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

948 Steps to 6 Figures by Learning Excel-VBA and Other Skills



Step 710 - GetUsersEmailAddress() - udf - internet


Exercise to find the method and convert to a function


Solution:


Function GetUsersEmailAddress()
Dim OL As Object, olAllUsers As Object, oExchUser As Object, oentry As Object, myitem As Object
    Dim User As String

    Set OL = CreateObject("outlook.application")
    Set olAllUsers = OL.Session.AddressLists.Item("All Users").AddressEntries

    User = OL.Session.CurrentUser.Name

    Set oentry = olAllUsers.Item(User)

    Set oExchUser = oentry.GetExchangeUser()

    GeUsersEmailAddress = oExchUser.PrimarySmtpAddress
End Function

   Table of Contents | Send us your feedback | © 2025 All Rights Reserved | Edit