Getting From Address in Sent Items with Exchange

J

Jim

I am trying to get the From Address from an email in the Sent Items
folder (i.e. I sent the email) while using Exchange.
Does anyone have any ideas?
I can get the from address if the email is in the inbox, but not if it
has been sent from outlook.
Thanks
 
S

Sue Mosher [MVP-Outlook]

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.

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

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

Jim

Thanks Sue, using PR_EMAIL does not seem to work when trying to get the
from address with exchange and in the Sent Items folder. Have you ever
tried that?
 
S

Sue Mosher [MVP-Outlook]

Yes, it should work fine. Could you show a code snippet?

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

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

Jim

Sure thanks Sue,

int PR_EMAIL = 972947486;
object email = safeMailItem.Sender.get_Fields(PR_EMAIL);

email will be null here if looking at an email that I sent using
exchange, but it will work fine to get the Sender address for an email I
received.

Thanks
 
D

Dmitry Streblechenko

PR_SMTP_ADDRESS is not available in the cached mode, but multivalueed
PR_EMS_AB_PROXY_ADDRESSES is:

PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

If safeMailItem.Sender.Type = "EX" Then

ProxyAddresses = safeMailItem.Sender.Fields(PR_EMS_AB_PROXY_ADDRESSES)

for i = LBound(ProxyAddresses) to UBound(ProxyAddresses)

if Left(ProxyAddresses(i), 5) = "SMTP:" Then

strAddress = Right(ProxyAddresses(i), Len(ProxyAddresses(i))-5)

Exit for

End If

Next

End If


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool\
 
J

Jim

Thank you Dmitry for your continued help on this.
I have tried this. I am using C# so it is a little different.
int PR_EMS_AB_PROXY_ADDRESSES = -2148470814;
object proxy = safeMailItem.Sender.get_Fields(PR_EMS_AB_PROXY_ADDRESSES);

proxy here is null.

Any ideas?
Thank you
 
D

Dmitry Streblechenko

The tag is wrong. If you want to define it as a signed int, 0x800F101E
is -2146496482.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

Jim said:
Thank you Dmitry for your continued help on this.
I have tried this. I am using C# so it is a little different.
int PR_EMS_AB_PROXY_ADDRESSES = -2148470814;
object proxy = safeMailItem.Sender.get_Fields(PR_EMS_AB_PROXY_ADDRESSES);

proxy here is null.

Any ideas?
Thank you

Dmitry said:
PR_SMTP_ADDRESS is not available in the cached mode, but multivalueed
PR_EMS_AB_PROXY_ADDRESSES is:

PR_EMS_AB_PROXY_ADDRESSES = &H800F101E

If safeMailItem.Sender.Type = "EX" Then

ProxyAddresses = safeMailItem.Sender.Fields(PR_EMS_AB_PROXY_ADDRESSES)

for i = LBound(ProxyAddresses) to UBound(ProxyAddresses)

if Left(ProxyAddresses(i), 5) = "SMTP:" Then

strAddress = Right(ProxyAddresses(i), Len(ProxyAddresses(i))-5)

Exit for

End If

Next

End If


Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool\

Sure thanks Sue,

int PR_EMAIL = 972947486;
object email = safeMailItem.Sender.get_Fields(PR_EMAIL);

email will be null here if looking at an email that I sent using
exchange, but it will work fine to get the Sender address for an email I
received.

Thanks


Sue Mosher [MVP-Outlook] wrote:

Yes, it should work fine. Could you show a code snippet?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top