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 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:
Dim oApp As Outlook.Application
Dim hello
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
:)
Re: Finding users email address from outlook ...
VB Code:
Dim OTL As New Outlook.Application
Debug.Print OTL.GetNamespace("MAPI").CurrentUser.AddressEntry
Debug.Print OTL.GetNamespace("MAPI").CurrentUser.Name
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:
Private Sub Workbook_Open()
Debug.Print Application.UserName
End Sub
because that is whats in the apps settings and can be changed so I wouldnt use that.