What API are you using? You can only use PR_SENDER_EMAIL_ADDRESS if you are
using CDO or Extended MAPI (C++ or Delphi only) or Redemption
(www.dimastr.com/redemption). That property isn't available directly in the
Outlook object model.
If you are coding for Outlook 2003 you could use SenderEmailAddress, but
unless you are writing a trusted COM addin that will fire the security
prompts.

Signature
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
> Hi,
>
[quoted text clipped - 8 lines]
> regards
> Vinayakc
Vinayakc - 23 Aug 2005 15:58 GMT
Thanks Ken,
Currently I am using extended MAPI.
My source code is like this:
//spMailItem is CComPtr<Outlook::_MailItem>
IUnknown* pUnknown;
IMessage *pMsg = NULL;
LPSPropValue lpsProp;
result = MAPIInitialize(NULL);
MAPIAllocateBuffer(sizeof(_SPropValue),(LPVOID*)&lpsProp);
spMailItem->get_MAPIOBJECT(&pUnknown);
pUnknown->QueryInterface(IID_IMessage, (void**)&pMsg);
result =
HrGetOneProp((LPMAPIPROP)pMsg,PR_SENDER_EMAIL_ADDRESS_W,(LPSPropValue
FAR *)&lpsProp);
if( result != S_OK )
{
LOG_ERR_MESSAGE( _T("HrGetOneProp()") , result );
//bRet = FALSE;
//goto Error;
return FALSE;
}
LPSTR hello;
hello =lpsProp->Value.lpszA;
if (lpsProp)
MAPIFreeBuffer(lpsProp);
lpsProp = NULL;
MAPIUninitialize();
My HrGetOneProp API is not working. It is returning some undefined
errorcode which is < 0.
I am new to Extended MAPI. So I could not figure out why this is
happening.
Thanks again
Regards
Vinayakc
Dmitry Streblechenko - 23 Aug 2005 18:43 GMT
What is that negative number returned by HrGetOneProp? Is it
MAPI_E_NOT_FOUND? Did you make sure PR_SENDER_EMAIL_ADDRESS actually exists
on the message in question? Did you look at that message with MdbView or
OutlookSpy?
Where does the message come from? Also note that you should not allocate
memory before calling HrGetOneProp - lpsProp will be allocated an populated
by HrGetOneProp (or IMessage::GetProps to be precise).
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> Thanks Ken,
>
[quoted text clipped - 44 lines]
> Regards
> Vinayakc
Vinayakc - 24 Aug 2005 07:45 GMT
Yes the error code return is : -2147221233 MAPI_E_NOT_FOUND.
I checked that mail's PR_SENDER_EMAIL_ADDRESS property with OutlookSpy.
It is showing me the mail address of sender.
Message is simple IPM.Note message.
I tried without allocating memory before calling HrGetOneProp. But it
is failing still.
I could not understand why it is happening??
one more thing. I can successfully access properties like
PR_MESSAGE_SIZE, PR_ENTRYID ut could not access PR_SENDER_EMAIL_ADDRESS
, PR_MESSAGE_CLASS.
Eagerly waiting for your help.
Thanks and Regards
Vinayakc
Dmitry Streblechenko - 24 Aug 2005 20:06 GMT
Are you *sure* it is the right message? Where does it come from
(folder.items, inspector, etc)? Did you try to read the PR_SUBJECT property
to verify that you are looking at the same message you check with
OutlookSpy?
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
> Yes the error code return is : -2147221233 MAPI_E_NOT_FOUND.
>
[quoted text clipped - 15 lines]
> Thanks and Regards
> Vinayakc
Vinayakc - 29 Aug 2005 08:14 GMT
Hi Dmirty,
I have just solved this problem. Actually i was reading property
PR_SENDER_EMAIL_ADDRESS_W
I have jsut changed it to
PR_SENDER_EMAIL_ADDRESS_A
& it is working now. I am now trying to find out the cause behind it.
I have made the changes you suggested as not to allocate MAPI buffer.
Thank you very much for valuable suggestions.
Regards
Vinayakc