Getting default Outlook email address

  • Thread starter Thread starter david.e.smith
  • Start date Start date
D

david.e.smith

I'm writing a .NET app which will run on a local workstation where
Outlook 2003 is installed. I simply want to get the default email
address of the current user. I've figured out how to get a MAPI-
style address (OU=etc) but all I want is the plain-jane address
([email protected]).

Here's how I get the MAPI address:

Dim oApp As New Outlook.Application
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim oRec As Outlook.Recipient = oNS.CurrentUser
Dim sMapiAddressHere As String = oRec.Address

Any help is greatly appreciated.
 
To get the SMTP address from an Exchange sender or recipient in versions before Outlook 2007, use Extended MAPI, CDO or, to avoid security prompts, Redemption and the PR_EMAIL (&H39FE001E) MAPI property to obtain the SMTP address from the AddressEntry object. See http://www.outlookcode.com/d/code/getsenderaddy.htm#redemption and http://www.cdolive.com/cdo5.htm#EMailAddressOfSender for examples. Note that CDO 1.21 is not officially supported in .NET languages. You might find Helmut's technique at http://www.outlookcode.com/codedetail.aspx?id=1112 useful.

See http://groups.google.com/group/micr...e_frm/thread/4d4d5fece24a2a7/ad2fcbb691d5bf18 for a discussion of how to do it with Cached Exchange Mode in Outlook 2003 or later.

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Thank you for that very thorough answer, and the accompanying links.
It's disappointing that something so trivial has to be so complex. I
understand that certain features should be blocked from scripting
access, but I'm writing a tool that is installed and fully trusted!

Are the 3rd party libraries (Redemption, CDO 1.2 and Mapi33) actually
just wrapping advanced methods that are buried within the Mapi32.dll
library? (I'll take the cue, too, and move over to the programming
room..)

Thanks again.
 
Back
Top