Re: retrieve the sender address using Extended MAPI (C++)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Dmitry,

Thank you very much for explanation.
Using IMAPISession::QueryIdentity I will receive the pointer to ENTRYID.
What should I do further with those ENTRYID to get the smtp address?

"Dmitry Streblechenko" wrote:

No, it is not guaranteed that the accoutn stamp will contain the SMTP
address.
It will contains the account id, which you will then need to use with the
IOlkAccountManager API to retrieve the accoutn details.
If no account is selected (the property is missing), use
IMAPISession::QueryIdentity to retrieve the current user details.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"Yaroslav K." <YaroslavK@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C1DC90E8-B316-46C0-8446-D1472EEB6BD3@xxxxxxxxxxxxxxxx
Hello!
I am writing the outlook add-in for Outlook 2003. There might be several
email account in outlook from which the message can be sent. I need to get
the sender address before the message is send out. In other words when the
user clicks 'Send' button in the inspector window (he might select some
email
account from which to send the message or use default) I need to know from
what account (email address) the message is sending. I have posted the
similar question in another forum and received the answer that the sender
address can be retrieved in the following way:
1). I should save the mail item
2). I should use the named property with the GUID of
"{00062008-0000-0000-C000-000000000046}" and
ID of 0x8581 to retrieve the sender address in the format accountNumber +
0x01 + SMTPAddress.
So I tried the following: at first I am saving the mail item in the
BeforeMessageSend handler and on the IMAPIAdviseThink notification
'fnevObjectCreated' I am checking whether the message is in outgoing
folder.
If the message is in outgoing folder I do the following:
static const GUID InetAcct_GUID = { 0x00062008, 0x0000, 0x0000, { 0xC0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };
LPSPropTagArray lpNamedPropTags = NULL;
MAPINAMEID NamedID = {0};
LPMAPINAMEID lpNamedID = &NamedID;
NamedID.lpguid = (LPGUID)&InetAcct_GUID;
NamedID.ulKind = MNID_ID;
NamedID.Kind.lID = 0x8581;
hResult = pMessage->GetIDsFromNames(
1,
&lpNamedID,
NULL,
&lpNamedPropTags);
if (SUCCEEDED(hResult) && lpNamedPropTags)
{
lpNamedPropTags->aulPropTag[0] =
CHANGE_PROP_TYPE(lpNamedPropTags->aulPropTag[0],PT_STRING8);
LPSPropValue lpProps = NULL;
ULONG cProps = 0;
hResult = pMessage->GetProps(
lpNamedPropTags,
NULL,
&cProps,
&lpProps);
if (SUCCEEDED(hResult) &&
1 == cProps &&
lpProps &&
PT_STRING8 == PROP_TYPE(lpProps[0].ulPropTag) &&
lpProps[0].Value.lpszA)
{
printf("Sender Email address = \"%s\"\n",lpProps[0].Value.lpszA);
}
MAPIFreeBuffer(lpProps);
MAPIFreeBuffer(lpNamedPropTags);
}

but PROP_TYPE(lpProps[0].ulPropTag) equals to PT_ERROR. (note: pMessage is
ATL::CComPtr<IMessage>). Btw, I tried this code when the message is
incoming
and it successfully retrieves the recipient address in the specified
format
mentioned above.

Am I correct in the way I am retrieving the sender address?
Is there another way to get the sender address before message is sent out?



.


Quantcast