Re: How to Read mail body using MAPI
- From: "Dmitry Streblechenko" <dmitry@xxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 10:04:12 -0700
First error is MAPI_E_INVALID_PARAMETER
Second one is MAPI_E_NOT_FOUND, meaning the message in question does not
have PR_BODY (which is perfectly valid).
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
<visalavats@xxxxxxxxxxxxx> wrote in message
news:1177683531.142409.214820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 27, 6:14 pm, "Stephen Griffin [MSFT]"
<sgrif...@xxxxxxxxxxxxxxxxxxxx> wrote:
Missing? What was the error code? Check like this:
if (PT_ERROR == PROP_TYPE(pVal[5].ulPropTag))
{
printf("Error: 0x%08X\n",pVal[5].Value.err);
}
As Dmitry pointed out - it's probably MAPI_E_NOT_ENOUGH_MEMORY.
You need to use OpenProperty and streams.
<visalav...@xxxxxxxxxxxxx> wrote in message
news:1177672147.528165.294390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 27, 12:28 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx>
wrote:
Firstly, Exchange provider limits the amount of data retrieved in a
single
call to around 32 kB.
Secondly, for the PR_BODY property, Exchange provider (depending on
the
version) will either return an error if the body is too large or will
truncate it to 255 characters.
Thirdly, your code never checks that the expected property is
returned.
If a
particular property is missing or it cannot be returned, the property
type
(lower 2 bytes) will be chnaged to PT_ERROR and SPropValue.Value.err
will
contain the appropriate error code (e.g. MAPI_E_NOT_ENOUGH_MEMORY).
You must check the property type:
if (pval[5].ulPropTag == PR_BODY)
{
...
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
<visalav...@xxxxxxxxxxxxx> wrote in message
news:1177651252.753255.193280@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 26, 9:43 pm, "Dmitry Streblechenko" <dmi...@xxxxxxxxxxx>
wrote:
Do you have a relevant snippet of your code that produces garbage?
Dmitry Streblechenko (MVP)http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
<visalav...@xxxxxxxxxxxxx> wrote in message
news:1177592943.724321.327010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
Please help in reading the mail content , I am only able to read
the
subject and other stuffs but when it comes to body PR_BODY the
content
is showing some junk values.
Is it possible to read mail body?????
I have been trying from many days please help me
Thanks
Vishal- Hide quoted text -
- Show quoted text -
/////////////////////
Hi,
The code is ...
void VishMapiTest()
{
IMAPISession *mapiSession = NULL;
IMsgStore *messageStore = NULL;
IMAPIFolder *inboxFolder = NULL;
IMAPITable *contents = NULL;
IMessage *message = NULL;
SRowSet *row = NULL;
SPropValue *properties = NULL;
ULONG values = 0;
HRESULT result = S_OK;
SPropValue *pval = NULL;
//Initialize
MAPIInitialize(NULL);
//Logon
MAPILogonEx(0, NULL, NULL, 0, (LPMAPISESSION *)&mapiSession);
//Open Message Store
mapiSession->OpenMsgStore(NULL, 0, NULL, NULL, 0, &messageStore);
// Open Inbox table
ULONG tags[] = { 1, PR_CE_IPM_INBOX_ENTRYID };
//
messageStore->GetProps((LPSPropTagArray)tags,
MAPI_UNICODE,
&values,
&properties);
// Open the entry ( Getting the Interface for Inbox Folder )
messageStore->OpenEntry(
properties[0].Value.bin.cb,
(LPENTRYID)properties[0].Value.bin.lpb,
NULL,
0,
NULL,
(LPUNKNOWN*)&inboxFolder);
GetPropsExample(&message);
inboxFolder->GetContentsTable(0, &contents);
SizedSPropTagArray(8/*Column_NumberOfColumns*/, columns) =
{
8/*Column_NumberOfColumns*/,
PR_ENTRYID,
PR_MESSAGE_FLAGS,
PR_SENDER_NAME,
PR_SUBJECT,
PR_MESSAGE_DELIVERY_TIME,
PR_BODY,
0x00010000, // PR_BODY_HTML, see MSDN
PR_RTF_COMPRESSED
};
contents->SetColumns((LPSPropTagArray)&columns, 0);
while(S_OK == (result = contents->QueryRows(1, 0, &row)))
{
// Column 0 - 4 contain the expected properties
// Columns 5 - 7 all contain NULL Values
pval = row->aRow[0].lpProps;
/
*****************************************************************/
pval[0-4] works properly
pval[5] does't work it should be PR_BODY its coming as junk
}
}// End of Function
Please help me...............
Thanks
Vishal- Hide quoted text -
- Show quoted text -
The PR_BODY is missing .............
Please help me- Hide quoted text -
- Show quoted text -
Hi Dmitry,
Thank you very much for your help.
I tried putting the error check,
I found the error code: -2147024809 ( Message not found )
it prints using this code ( printf("Error: 0x%08X
\n",pVal[5].Value.err); ) is " Error: 0x80070057 "
Please help me what to do next??????
I even tried reading the body using IMessage
// Open the mail body stream
IMessage *pMessage = NULL;
mapiSession->OpenEntry( pval[0].Value.bin.cb,//
properties[0].Value.bin.cb,
(LPENTRYID)pval[0].Value.bin.lpb, //
(LPENTRYID)properties[0].Value.bin.lpb,
NULL,
0,
NULL,
(LPUNKNOWN*)&pMessage);
//// I am able to get the pMessage pointer
but I am getting messagestream pointer.....
IStream * messageStream = NULL;
result = pMessage->OpenProperty(PR_BODY, &IID_IStream, STGM_READ,
MAPI_BEST_ACCESS ,
(LPUNKNOWN*)&messageStream);
the result is -2147221233
Please help once again ...
Thanks
vishal
.
- Follow-Ups:
- Re: How to Read mail body using MAPI
- From: visalavats
- Re: How to Read mail body using MAPI
- References:
- How to Read mail body using MAPI
- From: visalavats
- Re: How to Read mail body using MAPI
- From: Dmitry Streblechenko
- Re: How to Read mail body using MAPI
- From: visalavats
- Re: How to Read mail body using MAPI
- From: Dmitry Streblechenko
- Re: How to Read mail body using MAPI
- From: visalavats
- Re: How to Read mail body using MAPI
- From: Stephen Griffin [MSFT]
- Re: How to Read mail body using MAPI
- From: visalavats
- How to Read mail body using MAPI
- Prev by Date: PR_SUBJECT question
- Next by Date: Re: PR_SUBJECT question
- Previous by thread: Re: How to Read mail body using MAPI
- Next by thread: Re: How to Read mail body using MAPI
- Index(es):
Relevant Pages
|