Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Access VBA - Get Outlook Email Address or UserName (http://www.outlookbanter.com/outlook-vba/42971-access-vba-get-outlook-email.html)

Can Of Worms March 9th 07 03:10 PM

Access VBA - Get Outlook Email Address or UserName
 
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

nana March 9th 07 03:50 PM

Access VBA - Get Outlook Email Address or UserName
 
Hi,
Try http://www.cdolive.com/cdo5.htm#EMai...sOfCurrentUser

nana

"Can Of Worms" wrote:

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


Can Of Worms March 9th 07 04:05 PM

Access VBA - Get Outlook Email Address or UserName
 
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
----------

"nana" wrote:

Hi,
Try http://www.cdolive.com/cdo5.htm#EMai...sOfCurrentUser

nana



All times are GMT +1. The time now is 10:43 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com