When are outbound MailItem fields populated?

J

Joel Finkel

Folks,

I want to be able to check outbound mail messages to see if they are from a specific email address. If they are, I want to modify this address.

The clearest way to do this seems to be to add code to the Application_ItemSend event.

However, it appears that the following MAPI properties values are not even set at this point:

PR_SENDER_EMAIL_ADDRESS (&H0C1F001E)
PR_SENT_REPRESENTING_EMAIL_ADDRESS (&H0065001E)

So, I am wondering exactly when these values DO get set, and how is it possible to make the checks and modifications I want to make.

Thanks in advance. Thanks also to Dmitry, without whose Oulook Spy and Redemption code none of this work would even be possible.

Joel Finkel
(e-mail address removed)

Okay, why would I want to do this? My email changed, but I still receive mail sent to my old address (it is fowarded by the folks who puchased my domain). If I simply Reply to it, it retains my old email address. I do not want to have to remember to change it. It comes in through its own Outlook account.
 
D

Dmitry Streblechenko \(MVP\)

ItemSend is called before the message is handled to the transport provider
which sets these properties.
You can read them later when the message is moved to the Sent Items folder.
If you need to change the properties before the message is sent, try
something similar to http://www.dimastr.com/redemption/faq.htm#14
in case of SMTP. Under Exchange, use the SentOnBehalfOfName property

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

Folks,

I want to be able to check outbound mail messages to see if they are from a
specific email address. If they are, I want to modify this address.

The clearest way to do this seems to be to add code to the
Application_ItemSend event.

However, it appears that the following MAPI properties values are not even
set at this point:

PR_SENDER_EMAIL_ADDRESS (&H0C1F001E)
PR_SENT_REPRESENTING_EMAIL_ADDRESS (&H0065001E)

So, I am wondering exactly when these values DO get set, and how is it
possible to make the checks and modifications I want to make.

Thanks in advance. Thanks also to Dmitry, without whose Oulook Spy and
Redemption code none of this work would even be possible.

Joel Finkel
(e-mail address removed)

Okay, why would I want to do this? My email changed, but I still receive
mail sent to my old address (it is fowarded by the folks who puchased my
domain). If I simply Reply to it, it retains my old email address. I do
not want to have to remember to change it. It comes in through its own
Outlook account.
 
J

Joel Finkel

Dmitry,

The code on in your FAQ page would translate to this, which does not work.

Tag = sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "From")
sItem.Fields(Tag) = "(e-mail address removed)"
sItem.Subject = sItem.Subject
sItem.Save

This, however, does work:

Tag = sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}", "From")
foo = utils.HrSetOneProp(item.MAPIOBJECT, Tag or &H1E, "(e-mail address removed)", True)

Unfortunately, it does not solve the problem for me, in that I only want to make this change in the event that the original sender is my old email address. There must be some way to check for this.

Thanks again,

Joel Finkel
 
D

Dmitry Streblechenko \(MVP\)

In the first example you need to "or" the tag with the correct prop type
(&H1E)
I can only think of looking at a couple of named properties that are set by
Outlook if an account other than default is used to send the message. You
can then go to the registry and read thee name and address corresponding to
that account.

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

Dmitry,

The code on in your FAQ page would translate to this, which does not work.

Tag = sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}",
"From")
sItem.Fields(Tag) = "(e-mail address removed)"
sItem.Subject = sItem.Subject
sItem.Save

This, however, does work:

Tag = sItem.GetIDsFromNames("{00020386-0000-0000-C000-000000000046}",
"From")
foo = utils.HrSetOneProp(item.MAPIOBJECT, Tag or &H1E,
"(e-mail address removed)", True)

Unfortunately, it does not solve the problem for me, in that I only want to
make this change in the event that the original sender is my old email
address. There must be some way to check for this.

Thanks again,

Joel Finkel
 

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