Programmatically changing the message's sender field in MAPI.

J

JahMic

Using outlook as a user, there are 2 ways to change the 'from' field,
one is actually choosing or typing in address in the 'from' line, but
that outputs a 'sent on behalf of' type of message. Using the
Accounts drop-down changes the low-level fields. The latter is
functionality I want.

Is it actually as easy as changing the PR_SENDER properties? Or do I
have to actually login into that account and send it from there? If
so, how can I take all my existing properties with me?

Of course, if there is a simpler way of doing this using OOM (without
security warnings), I would like to know about that too.

Thanks in advance,

J
 
D

Dmitry Streblechenko

Outlook 2007 - MailItem.SendUsingAccount property
MAPI - two named properties
(http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8580001E
and
http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-C000-000000000046}/8581001E)
that contain the id and name of the account.
<plug>Redemption - RDOMail.Account property (see
http://www.dimastr.com/redemption/rdo/RDOMail.htm) </plug>

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

JahMic

Well, it would have been easier if I just had to support o2007 or
could use redemption.

Insteadt, I had to do the following:

To check the sender:

OnSend,

check the to see if the named property 0x8581 (same as below) is set,
if so, parse that a bit to get the email account.
if not present, just the default sender via session QueryIdentity.

To change the sender,

Enumerate and find the indended account, via the IOlkAccountManager
api.
and set the PR_PRIMARY_SEND_ACCT & PR_NEXT_SEND_ACCT accordingly.

Too much work..

J
 

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