VC6 Add-in email issues

  • Thread starter Thread starter Mark Smith
  • Start date Start date
M

Mark Smith

I am trying to write an Add-In (VC6) that allows me to export an email to
another program. I am currently working with Outlook 2000. Most things are
working fine, but there are a few things I can't figure out.

There doesn't seem to be any way to get the email adress of the sender of an
email. The MailItem object has GetSenderName and GetSentOnBehalfOfName, but
these just give me the display name. Is there some kind of look up I can do
given the display name? Or some other way to get the sender's address?

Also, if I receive an email that is sent to an address without a domain
(e.g. just to NAME, not to NAME@DOMAIN), is there any way to get that
domain? I tried the Recipients::ResolveAll method, but that didn't do
anything.

Thanks!
Mark
 
In Outlook 2003, you can use the MailItem.SenderEmailAddress, but note that
it's subject to security prompts.

In earlier versions, there is no Outlook property that returns the sender's
email address. You can either use CDO (or Redemption to avoid security
prompts -- http://www.dimastr.com/redemption/) to get the From address or
use Outlook to get the Reply To address. Sample code at
http://www.outlookcode.com/d/code/getsenderaddy.htm

To get the SMTP address from an Exchange sender or recipient, use CDO or
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.

To answer you're other question, the first recipient address would be
MailItem.Recipients(1).Address
 
Thanks for your help! Incidentally I did figure out a way to get the
sender's mail address without using these methods. In C++ there is a
MailItem::get_MAPIOBJECT function which returns the MAPI IMessage interface,
from which you can get the sender's address, among other things. I imagine
this is similar to what the Redemption library does.

As for my other question, I guess I wasn't clear enough. Let me try again.
I send an email address from Outlook to a distribution list, (e-mail address removed)
(distribution is handled by the server), which includes my email address. I
download the message in Outlook. When I look at
MailItem.Recipients(1).Address, I see "all", not (e-mail address removed). Is there a
way to ensure that I get the whole address, including the domain,
"domain.com"?

Mark
 
Sorry, that was my fault for reading VB for VC and not steering you to
Extended MAPI in the first place.

If you want the SMTP address from an Exchange DL, you can't use
MailItem.Recipients(1).Address. Outlook knows nothing about SMTP addresses
for Exchange acocunt. You'll need to drop into ExMAPI again and use the
PR_EMAIL field.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I can't find a PR_EMAIL field anywhere in the documentation or code. What
is it? How can I use it?

Mark
 
Back
Top