Get current user's email address

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,

In VB6 I will create in code a mail for sending to some recipients.
Can I get the current user's email address, the one who sends the
email ?

I am using the code below:

Set olk_APP = GetObject(, "Outlook.application")

Set var_mail = olk_APP.CreateItem(0)

If with the above code I am not able to retrieve the address, is there
any other way of creating mail and be able to retrieve it ?

Thanks a lot.
 
Thanks Dmitry for you message.

I used the properties below, but none of them returns the email in
(e-mail address removed) format..

List1.AddItem
olk_APP.Application.GetNamespace("MAPI").CurrentUser.Name
List1.AddItem
olk_APP.Application.GetNamespace("MAPI").CurrentUser.Address

Am I missing sth ?
 
If you are using Outlook 2007, you can use
Application.Session.CurrentUser.AddressEntry.GetExchangeUser.PrimarySmtpAddress

Otherwise you will need to use Extended MAPI, CDO 1.21 or Redemption.to read
teh PR_SMTP_ADDRESS (online mode only) or PR_EMS_AB_PROXY_ADDRESSES MAPI
properties.
Redemption also exposes the default SMTP address through the
RDOAddressEntry.SmtpAddress properrty:

RDOSession.CurrentUser.SmtpAddress

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
My program is installed on client machines, so I cannot control the
version of their Outlook (if they will have) :-(
Procedure for sending mail will check for outlook for creating the
automatic mail. I needed to include the sender email address in the
body, so my company user who receives the mail from clients, to copy
once the email body (including user's email address and other info for
program...)

The MAPI requires server name (host, port), isn't ? Which mean in my
case cannot be used.. Does CDO or Redemption need any info for
server ?
 
You are probably thinking about IMAP4. Extended MAPI (accessible from C++ or
Delphi) is what Outlook uses natively and both CDO 1.21 and Redemption wrap.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
I had in mind the SMTP I used in ASP.

I checked CDO for returning the email address.

Thanks a lot!
 
Back
Top