excel vba interface with outlook (office 2000)

  • Thread starter Thread starter tmountjr
  • Start date Start date
T

tmountjr

I'm writing (or trying to write) some code in Excel VBA to extract the
current logged-in user's email address from Outlook. I figured out how
to go through the namespace and access the currentuser:

Sub test()

Dim a As Recipient
Set a = Outlook.Application.GetNamespace("MAPI").currentUser

MsgBox a.AddressEntry.Address

End Sub

This returned a cryptic string that I can parse and bring to a usable
email address, but the problem is that it comes up with message saying
that it needs special permission to access the information. The error
box that comes up is: "A program is trying to access e-mail addresses
you have stored in Outlook. Do you want to allow this?" I could't find
anything in the security informatino to stop that from coming up. I
need this to be seamless so it can fit in an automated process. Is this
the best way to retrieve an email address from a login, and if so, how
do I stop that message from coming up?
 
Hi,

I don't think you can get this through Outlook (version newer than 2000 sp2)
without running into this security warning. You may want to look into a
product called "Outlook Redemption", which may allow you to get around the
security warning.

Another option is to look in the registry for the user's email address. One
place I found my email addresses is subkeys of this registry key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\UnreadMail\

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Back
Top