Results 1 to 2 of 2

Thread: Finding users email address from outlook ...

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    32

    Finding users email address from outlook ...

    I have a spreadsheet which I'd like to auto run an macro upon opening, capture the user's email address based upon which will then do a set list of custom actions dependant upon the user.

    The "Everything else" I've got written but am having trouble being able to find the user's email address from outlook ...

    I could use
    VB Code:
    1. application.username
    but the 'username' is listed as an ID such as 'abc123' rather than the users name so I'd then need to hard code a translation that shows that 'abc123' = 'Clifford Wright' etc ..

    anyone any ideas?

    I did try;

    VB Code:
    1. Dim oApp As Outlook.Application
    2. Dim hello
    3.  
    4. hello = oApp.Application.UserName

    but I think I'm mixing things up here plus I think the outlook username will also be 'abc123'

    Any ideas how I can find the user's default email address?

    Cheers


  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Finding users email address from outlook ...

    VB Code:
    1. Dim OTL As New Outlook.Application
    2.     Debug.Print OTL.GetNamespace("MAPI").CurrentUser.AddressEntry
    3.     Debug.Print OTL.GetNamespace("MAPI").CurrentUser.Name
    4.     Set OTL = Nothing

    but.. if this is a network environment... use this:

    Debug.Print Environ("username")

    in MOST cases that will work, and it will give you the current logged in user's "log in" name

    and a less reliable way:
    VB Code:
    1. Private Sub Workbook_Open()
    2.     Debug.Print Application.UserName
    3. End Sub
    because that is whats in the apps settings and can be changed so I wouldnt use that.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width