LPMESSAGE* outMessage=new LPMESSAGE();// NULL;
LPSTREAM pMimeStream = NULL;
IConverterSession *pConverterSession = NULL;
DWORD dwFileSize = 0;
HANDLE hFile = NULL;
LPVOID pvData = NULL;
HGLOBAL hGlobal = NULL;
DWORD dwBytesRead = 0;
BOOL bRead = FALSE;
// open file
hFile = CreateFile((LPCSTR)inMimeFile, GENERIC_READ,1, NULL,
OPEN_EXISTING, 0,NULL);
dwFileSize = GetFileSize(hFile, NULL);
// alloc memory based on file size
hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
pvData = GlobalLock(hGlobal);
// read file and store in global memory
bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
GlobalUnlock(hGlobal);
CloseHandle(hFile);
hr = CreateStreamOnHGlobal(hGlobal, TRUE, &pMimeStream);
if(hr==S_OK)
{
hr=CoCreateInstance(CLSID_IConverterSession,NULL,CLSCTX_INPROC_SERVER,IID_IConverterSession,
(void **)&pConverterSession);
if(hr==S_OK)
{
hr=pConverterSession->SetEncoding(IET_BASE64);
if(hr==S_OK)
{
hr=pConverterSession-
>MIMEToMAPI(pMimeStream,*outMessage,NULL,CCSF_SMTP | CCSF_INCLUDE_BCC|
CCSF_NO_MSGID);
if(hr==S_OK)
{
ipmMessage->Mes=*outMessage;
}
}
}
}
return hr;
When i call MIMETo MAPI method i am getting error code -2147287015.
I suppose this is STG_E_SEEKERROR.
What is wrong here?
My other variables are:
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);
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;
/*!Inteface defining the methods that are used to convert mime to
mapi*/
interface DECLSPEC_UUID("4B401570-B77B-11D0-9DA5-00C04FD65685")
IConverterSession : public IUnknown
{
private:
STDMETHOD(placeholder0)() PURE;
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;
};
help me
miztaken
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<justju...@gmail.com> wrote in message
news:0b318fcc-4ce4-4717...@s37g2000prg.googlegroups.com...
LPWSTR lpWideCharStr = NULL;
ULONG cbStrSize = 0L;
LPSTORAGE pStorage = NULL;
LPMSGSESS pMsgSession = NULL;
LPMALLOC pMalloc=MAPIGetDefaultMalloc();
cbStrSize=MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,outMsgFile,-1,lpWideCharStr,
0);
MAPIAllocateBuffer(cbStrSize * sizeof(WCHAR),(LPVOID
*)&lpWideCharStr);
MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,outMsgFile,-1,lpWideCharStr,cbStrSize);
hr=StgCreateDocfile(lpWideCharStr,STGM_CREATE|STGM_READWRITE|
STGM_TRANSACTED,0,&pStorage);
hr=OpenIMsgSession(pMalloc,0,&pMsgSession);
hr=OpenIMsgOnIStg(pMsgSession,MAPIAllocateBuffer,MAPIAllocateMore,MAPIFreeBuffer,pMalloc,NULL,pStorage,NULL,
0,0,&outMessage);
hr=WriteClassStg(pStorage,CLSID_MailMessage);
Till here hr returns 0 i.e S_OK
but after that when i execute:
hr=pConverterSession-
>MIMEToMAPI(pMimeStream,outMessage,NULL,CCSF_SMTP);// |
CCSF_INCLUDE_BCC|CCSF_NO_MSGID);
Then it returns the same error:
2147287015 (STG_E_SEEKERROR)
Help me
Its working now. It stated working.
But when i tried to open the saved MSG file then it says "Cannot start
microsoft office outlook. Unable to read the item."
The size of MSG file is always 5 KB.
From beginning to end.. all hr returned S_OK but i am unable to get
the result.
What is wrong.
help me
miztaken
BTW outlook spy saves it correctly.
I dont have any clue what is wrong here.
Thank You
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<justju...@gmail.com> wrote in message
news:3eb8c2be-0157-4b42...@q27g2000prf.googlegroups.com...
And BTW is the method MIMETOMAPI enough to convert EML files (Outlook
express file) to MSG files (Office Outlook) files or we need some MIME
parser?
Thank You
--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
<justju...@gmail.com> wrote in message
news:b414b611-2f1e-4185...@s8g2000prg.googlegroups.com...