Log in

View Full Version : Solved: How do you get the current user's default email address?



SherryO
10-24-2006, 10:37 AM
Does anyone have some code that will return the current user's default email address. We use Outlook 2002. I need to know the user@company.com addresss or their listing in the Global Address List.

Thank you soo much,
SherryO

mvidas
10-24-2006, 11:01 AM
Hi Sherry,Sub WhatsMyEntry()
With GetNamespace("MAPI").CurrentUser
MsgBox .AddressEntry & vbCrLf & .Address
End With
End SubMatt

SherryO
10-24-2006, 11:08 AM
I'm getting the Outlook security popup which I would like to avoid, also it's displaying my name as it appears in the Global Address List rather than an email address SMTP. Is there a way around that? Thanks!!!!

mvidas
10-24-2006, 11:32 AM
Hi Sherry,

To avoid the security popup, there are a few things you could use.

You could get a program like ClickYes which seeks out these popups and clicks them automatically http://www.contextmagic.com/express-clickyes/ (http://www.contextmagic.com/express-clickyes/)

One better from that is http://www.mapilab.com/outlook/security/ (http://www.mapilab.com/outlook/security/) which is an outlook COM add-in that removes that popup as it comes

Or, depending on how much you want to remove it, you could use the Redemption object ( http://www.dimastr.com/redemption/ (http://www.dimastr.com/redemption/) ), very powerful component that uses extended mapi.
Take a look at http://www.outlookcode.com/threads.aspx?forumid=2&messageid=19973 to see how to use redemption for this

If you have CDO installed on the computer (an optional component when setting up MS Office/outlook): With CreateObject("MAPI.Session")
.Logon "", "", False, False, 0
MsgBox .GetAddressEntry(GetNamespace("MAPI").CurrentUser.EntryID) _
.Fields(&H39FE001E).Value
End With
The cdo session has a .getaddressentry method which needs the entry id of a user (seemingly random string of characters, obviously not). You can probably get that using CDO too, but using the mapi session shown above you can get the entryid of the current user as well.

Matt