Access VBA - Get Outlook Email Address or UserName

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am building a front end to a database in Access 2000, and want to ping
Outlook for the current user's User Name or email address. Either will work,
and I assume they are essentially the same thing, just the address has the
@company.com attached to the end.

If it is possible to do this with Outlook closed, then that would be ideal,
however I can work with solutions that require Outlook to be open.
Unfortunately, I can't use their NT logon ID, since that is about an 92%
match to their email address ID and I don't have access to the list of NT
logon IDs. I do have access to the email address list, so trying to work with
that.

I am fairly new to VBA, so library references and how to properly call what
I am using would be very helpful as well.

Thanks!
-CoW
 
Thank you! From the desciption, this looks like it will do what I want.

Now, how/where do I put this code? The 'Public Const' line gets highlighted
red when I paste it in, regardless of if I paste inside or outside of a sub.
(Code below for quick reference)

Again, fairly new to VBA :)

Thanks.

-CoW
------------
' MAPI property tag for e-mail addresses
Public Const PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

' Array for e-mail addresses
Dim strAddresses

' Get current user object
Set objAddressEntry = objSession.CurrentUser

' Get the fields collection of the address entry
Set objFields = objAddressEntry.Fields

' Pull out proxy addresses
Set objMailAddresses = objFields.Item(PR_EMS_AB_PROXY_ADDRESSES)
If Not objMailAddresses Is Nothing Then

' Add the addresses to an array
strAddresses = objMailAddresses.Value

' Loop through the array and display single address
For intCounter = LBound(strAddresses) To UBound(strAddresses)
MsgBox intCounter & ". E-mail address: " & strAddresses(intCounter)
Next
End If
 
Back
Top