MAPIToMIMEStm gives error 0x40380 in Outlook 2010(64-bit)

May 11, 2010 at 12:35 PM

Hi,

I am using the following code to retrieve rfc822 format of mails received on Outlook 2010 (64 - bit version)
This code works perfectly fine for newly received messages on Outlook 2010 but fails for messages already stored in a folder.

 hr = pConverterSession->MAPIToMIMEStm (lpMessage,lpMimeStm,CCSF_INCLUDE_BCC |CCSF_8BITHEADERS);

   lpMimeStm->Stat(&stg,STATFLAG_NONAME);

   if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0))

    {

          lpMimeStm->Seek(dwBegin, STREAM_SEEK_SET, NULL);

          ulLenMimeStream = stg.cbSize.LowPart; 

          lpMimeStm->Read( szMimeStream, ulLenMimeStream, &ulred );

    }                     

 

If I open a message stored in Outlook 2010 and call pConverterSession->MAPIToMIMEStm, it returns MAPI_W_ERRORS_RETURNED.

Further, expression if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0)) fails , and stg.cbSize.LowPart is 0. So, there is no output.

Please, help me fix this issue as I want to retrieve rfc822 format of all the mails received on Outlook 2010.

 

Thanks and Best Regards,

Savinalini

Coordinator
May 14, 2010 at 6:13 PM

I haven’t encountered this myself. You should probably open a case to have us investigate this.

From: savinalini [mailto:notifications@codeplex.com]
Sent: Tuesday, May 11, 2010 8:35 AM
To: Stephen Griffin
Subject: MAPIToMIMEStm gives error 0x40380 in Outlook 2010(64-bit) [MFCMAPI:212253]

From: savinalini

Hi,

I am using the following code to retrieve rfc822 format of mails received on Outlook 2010 (64 - bit version)
This code works perfectly fine for newly received messages on Outlook 2010 but fails for messages already stored in a folder.

hr = pConverterSession->MAPIToMIMEStm (lpMessage,lpMimeStm,CCSF_INCLUDE_BCC |CCSF_8BITHEADERS);

lpMimeStm->Stat(&stg,STATFLAG_NONAME);

if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0))

{

lpMimeStm->Seek(dwBegin, STREAM_SEEK_SET, NULL);

ulLenMimeStream = stg.cbSize.LowPart;

lpMimeStm->Read( szMimeStream, ulLenMimeStream, &ulred );

}

If I open a message stored in Outlook 2010 and call pConverterSession->MAPIToMIMEStm, it returns MAPI_W_ERRORS_RETURNED.

Further, expression if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0)) fails , and stg.cbSize.LowPart is 0. So, there is no output.

Please, help me fix this issue as I want to retrieve rfc822 format of all the mails received on Outlook 2010.

Thanks and Best Regards,

Savinalini

Read the full discussion online.

To add a post to this discussion, reply to this email (MFCMAPI@discussions.codeplex.com)

To start a new discussion for this project, email MFCMAPI@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

May 18, 2010 at 9:47 AM
Dear Stephen Griffin,

Would you please guide me where should I open this case.

Thanks and Best Regards,
Savinalini Vinayak

On Fri, May 14, 2010 at 11:43 PM, sgriffin <notifications@codeplex.com> wrote:
> From: sgriffin
>
> I haven’t encountered this myself. You should probably open a case to have
> us investigate this.
>
> From: savinalini [mailto:[email removed]
> Sent: Tuesday, May 11, 2010 8:35 AM
> To: Stephen Griffin
> Subject: MAPIToMIMEStm gives error 0x40380 in Outlook 2010(64-bit)
> [MFCMAPI:212253]
>
> From: savinalini
>
> Hi,
>
> I am using the following code to retrieve rfc822 format of mails received on
> Outlook 2010 (64 - bit version)
> This code works perfectly fine for newly received messages on Outlook 2010
> but fails for messages already stored in a folder.
>
> hr = pConverterSession->MAPIToMIMEStm (lpMessage,lpMimeStm,CCSF_INCLUDE_BCC
> |CCSF_8BITHEADERS);
>
> lpMimeStm->Stat(&stg,STATFLAG_NONAME);
>
> if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0))
>
> {
>
> lpMimeStm->Seek(dwBegin, STREAM_SEEK_SET, NULL);
>
> ulLenMimeStream = stg.cbSize.LowPart;
>
> lpMimeStm->Read( szMimeStream, ulLenMimeStream, &ulred );
>
> }
>
> If I open a message stored in Outlook 2010 and call
> pConverterSession->MAPIToMIMEStm, it returns MAPI_W_ERRORS_RETURNED.
>
> Further, expression if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <=
> 0)) fails , and stg.cbSize.LowPart is 0. So, there is no output.
>
> Please, help me fix this issue as I want to retrieve rfc822 format of all
> the mails received on Outlook 2010.
>
> Thanks and Best Regards,
>
> Savinalini
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe on CodePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at CodePlex.com
May 18, 2010 at 10:12 AM
Dear Stephen Griffin,

Following is the complete code which I am executing. The same code runs perfectly fine for Outlook 2010 32 bit version but MAPIToMIMEStm() fails with error MAPI_W_ERRORS_RETURNED in case of Outlook 2010 64 bit.
Even if i ignore this error, and execute further, the following expression
      if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= > 0)) fails ,
     and stg.cbSize.LowPart is 0. So, there is no output.


LPMAPIFOLDER     lpFolder                   =  NULL;
LPMAPITABLE        lpContentsTable       =  NULL;
LPSRowSet             pRows                    =  NULL;
ULONG                   ulFlags                    =   0;
LPSTREAM             lpMimeStm              = NULL;
LPMAPITABLE       lpMapiStoresTable   = NULL;

enum
{
   ePR_ENTRYID,
   NUM_COLS
};
static SizedSPropTagArray(NUM_COLS,
sptCols) =
{
  NUM_COLS,
  PR_ENTRYID
};

MAPIInitialize(NULL);
ulFlags = MAPI_ALLOW_OTHERS | MAPI_USE_DEFAULT | MAPI_EXTENDED;
MAPILogonEx( NULL,NULL,NULL,ulFlags,&lpSession );
lpSession->OpenAddressBook( 0L,  NULL,  NULL,  &lpAddrBook);

CoInitialize(0);
CoCreateInstance(CLSID_IConverterSession, NULL,CLSCTX_INPROC_SERVER, IID_IConverterSession, (void**)&pConverterSession);

pConverterSession->SetEncoding(IET_QP);

pConverterSession->SetAddressBook(lpAddrBook);

pConverterSession->SetSaveFormat(SAVE_RFC1521);

ulFlags             =  MAPI_MODIFY| MAPI_DEFERRED_ERRORS | MAPI_BEST_ACCESS;

lpMsgStore->OpenEntry (    cbEntryID,
                                        lpEntryID,
                                        NULL,
                                        ulFlags,                      
                                        &ulObjType,
                                        (LPUNKNOWN FAR *) &lpFolder    );

lpFolder->GetContentsTable(0, &lpContentsTable);

HrQueryAllRows(   lpContentsTable, (LPSPropTagArray) &sptCols, NULL,NULL,0,&pRows);

for (ulMsgCount = 0; ulMsgCount < pRows -> cRows; ulMsgCount++)
{

ulFlags  = MAPI_MODIFY | MAPI_BEST_ACCESS |MAPI_DEFERRED_ERRORS;

lpFolder->OpenEntry(  

           pRows -> aRow[ulMsgCount].lpProps[ePR_ENTRYID].Value.bin.cb,

(LPENTRYID)pRows -> aRow[ulMsgCount].lpProps[ePR_ENTRYID].Value.bin.lpb,

           NULL,

           ulFlags,

           &ulObjType,

          (LPUNKNOWN FAR *) &lpMessage);

}

CreateStreamOnHGlobal(NULL, TRUE, &lpMimeStm);


pConverterSession->MAPIToMIMEStm(lpMessage,lpMimeStm,CCSF_INCLUDE_BCC | CCSF_8BITHEADERS);

lpMimeStm->Stat(&stg,STATFLAG_NONAME);

if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0))
{
lpMimeStm->Seek(dwBegin, STREAM_SEEK_SET, NULL);
}

Header file :


#define CONVERTERSESSION_H_INCLUDED
#define USES_IID_IConverterSession
 
#include <comdef.h>
#include <Guiddef.h>

#if !defined(INITGUID) || defined(USES_IID_IConverterSession)
DEFINE_GUID(CLSID_IConverterSession, 0x4e3a7680, 0xb77a, 0x11d0,0x9d, 0xa5, 0x0, 0xc0, 0x4f, 0xd6, 0x56, 0x85);
DEFINE_GUID(IID_IConverterSession, 0x4b401570, 0xb77b, 0x11d0, 0x9d,0xa5, 0x0, 0xc0, 0x4f, 0xd6, 0x56, 0x85);
#endif

typedef enum tagENCODINGTYPE {
IET_BINARY = 0,
IET_BASE64 = 1,
IET_UUENCODE = 2,
IET_QP = 3,
IET_7BIT = 4,
IET_8BIT = 5,
IET_INETCSET = 6,
IET_UNICODE = 7,
IET_RFC1522 = 8,
IET_ENCODED = 9,
IET_CURRENT = 10,
IET_UNKNOWN = 11,
IET_BINHEX40 = 12,
IET_LAST = 13
} ENCODINGTYPE;

typedef enum tagMIMESAVETYPE {
SAVE_RFC822 = 0,
SAVE_RFC1521 = 1

} MIMESAVETYPE;

typedef enum tagCCSF {
CCSF_SMTP        = 0x0002,
CCSF_NOHEADERS   = 0x0004,
CCSF_NO_MSGID    = 0x4000,
CCSF_USE_RTF     = 0x0080,
CCSF_INCLUDE_BCC = 0x0020,
CCSF_USE_TNEF  = 0x0010,
CCSF_8BITHEADERS = 0x0040
} CCSF;

class __declspec(uuid("4e3a7680-b77a-11d0-9da5-00c04fd65685"))
CConverterSession;


interface __declspec(uuid("4b401570-b77b-11d0-9da5-00c04fd65685"))
IConverterSession;

_COM_SMARTPTR_TYPEDEF(IConverterSession,__uuidof(IConverterSession));




interface IConverterSession : public IUnknown
{

public:

STDMETHOD(SetAddressBook) ( LPADRBOOK pAddrBook ) PURE;
STDMETHOD(SetEncoding)(ENCODINGTYPE et) PURE;

private:

STDMETHOD(placeholder1)() PURE;
public:

STDMETHOD(MIMEToMAPI)(LPSTREAM pstm,LPMESSAGE pmsg,LPCSTR pszSrcSrv,ULONG ulFlags) PURE;
STDMETHOD(MAPIToMIMEStm)(LPMESSAGE pmsg,LPSTREAM pstm,ULONG ulFlags) PURE;

private:
STDMETHOD(placeholder2)() PURE;
STDMETHOD(placeholder3)() PURE;
STDMETHOD(placeholder4)() PURE;

public:

STDMETHOD(SetTextWrapping(BOOL fWrapText,ULONG ulWrapWidth)) PURE;

STDMETHOD(SetSaveFormat(MIMESAVETYPE mstSaveFormat)) PURE;

private:
STDMETHOD(placeholder5)() PURE;
STDMETHOD(placeholder6)() PURE;


};

Would you please help me fix this issue.

Thanks and Best Regards,
Savinalini Vinayak

On Tue, May 18, 2010 at 3:17 PM, Savi Vinayak <vinayak.savi@gmail.com> wrote:
Dear Stephen Griffin,

Would you please guide me where should I open this case.

Thanks and Best Regards,
Savinalini Vinayak

On Fri, May 14, 2010 at 11:43 PM, sgriffin <notifications@codeplex.com> wrote:
> From: sgriffin
>
> I haven’t encountered this myself. You should probably open a case to have
> us investigate this.
>
> From: savinalini [mailto:[email removed]]
> Sent: Tuesday, May 11, 2010 8:35 AM
> To: Stephen Griffin
> Subject: MAPIToMIMEStm gives error 0x40380 in Outlook 2010(64-bit)
> [MFCMAPI:212253]
>
> From: savinalini
>
> Hi,
>
> I am using the following code to retrieve rfc822 format of mails received on
> Outlook 2010 (64 - bit version)
> This code works perfectly fine for newly received messages on Outlook 2010
> but fails for messages already stored in a folder.
>
> hr = pConverterSession->MAPIToMIMEStm (lpMessage,lpMimeStm,CCSF_INCLUDE_BCC
> |CCSF_8BITHEADERS);
>
> lpMimeStm->Stat(&stg,STATFLAG_NONAME);
>
> if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0))
>
> {
>
> lpMimeStm->Seek(dwBegin, STREAM_SEEK_SET, NULL);
>
> ulLenMimeStream = stg.cbSize.LowPart;
>
> lpMimeStm->Read( szMimeStream, ulLenMimeStream, &ulred );
>
> }
>
> If I open a message stored in Outlook 2010 and call
> pConverterSession->MAPIToMIMEStm, it returns MAPI_W_ERRORS_RETURNED.
>
> Further, expression if (!(stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <=
> 0)) fails , and stg.cbSize.LowPart is 0. So, there is no output.
>
> Please, help me fix this issue as I want to retrieve rfc822 format of all
> the mails received on Outlook 2010.
>
> Thanks and Best Regards,
>
> Savinalini
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> (MFCMAPI@discussions.codeplex.com)
>
> To start a new discussion for this project, email
> MFCMAPI@discussions.codeplex.com
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> (MFCMAPI@discussions.codeplex.com)
>
> To start a new discussion for this project, email
> MFCMAPI@discussions.codeplex.com
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe on CodePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at CodePlex.com

May 20, 2010 at 11:57 AM
Dear Stephen Griffin,

I would like to add more information on this issue.

I have observed that MAPIToMIMEStm() fails with error MAPI_W_ERRORS_RETURNED for the mails which are moved from some other pst file to default pst file .

For Example, there are two outlook datafiles a.pst and b.pst.
a.pst is default datafile. If I delete b.pst file, Outlook moves the mails to a.pst file.
MAPIToMIMEStm() fails for these mails moved from b.pst file to a.pst file.
Though, these messages are regular IPM.Note messages

Would you please suggest a way to deal with this issue.

I would be grateful.

Best Regards,
Savinalini
Oct 17, 2010 at 7:49 PM

Hi,

Try DCI Mail Processor API.

The 4 API for mail messages convertion

link: http://dci-software.com/MailProcessor/mpmain.html