Accessing the outlook express 6 mails in dbx format
#include "stdafx.h"
#include "ca7.h"
/*int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}*/
//INT main()
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr = CoInitialize(0);
if(FAILED(hr)) {
MessageBox(0,_T("Error CoInitialize."), _T("Demo Error"),0);
}
IStoreFolder* pFolder = NULL;
IStoreNamespace* pStore = NULL;
IStream* pStream = NULL;
FOLDERPROPS fprops = {0};
MESSAGEPROPS mprops = {0};
HENUMSTORE hFEnum = NULL;
HENUMSTORE hMEnum = NULL;
HRESULT hr2;
// Create an instance of an IStoreNamespace object.
CoCreateInstance(
CLSID_StoreNamespace, // Namespace ClassID
NULL, // Outer unknown that aggregates the
new object
CLSCTX_INPROC_SERVER, // a server dll
IID_IStoreNamespace, // interface ID
(LPVOID*)&pStore); // The returned IStoreNamespace object
// Initialize the new Namespace object.
pStore->Initialize(NULL, NULL);
// Open the first enumerated folder.
fprops.cbSize = sizeof(fprops);
pStore->GetFirstSubFolder(FOLDERID_ROOT, &fprops, &hFEnum);
pStore->GetNextSubFolder(hFEnum,&fprops);
pStore->GetNextSubFolder(hFEnum,&fprops);
pStore->GetNextSubFolder(hFEnum,&fprops);
pStore->OpenFolder(fprops.dwFolderId, 0, &pFolder);
// If a message exists, ...
if (fprops.cMessage > 0)
{
// ...open the first message in the first folder.
mprops.cbSize = sizeof(mprops);
int ixx = 0;
pFolder->GetFirstMessage(0, 0, MESSAGEID_FIRST, &mprops,
&hMEnum);
do
{
ixx++;
pStream = NULL;
//puts(mprops.pszDisplayFrom);
//if ((mprops.dwState & 0x0002)==0x002)
printf("%X]Email from %s Subject %s %02X
\n",mprops.dwMessageId,mprops.pszDisplayFrom,mprops.pszSubject,mprops.dwState);
pFolder->OpenMessage(mprops.dwMessageId, IID_IStream,
(VOID **) &pStream);
// Print the message content to a stream.
HRESULT hr = S_OK;
char szBuff[100];
ULONG cbRead = 1;
while (hr == S_OK && cbRead > 0)
{
hr = pStream->Read(szBuff, sizeof(szBuff)-1, &cbRead);
if (hr == S_OK)
{
szBuff[cbRead] = NULL;
//puts(szBuff);
}
}
pFolder->FreeMessageProps(&mprops);
} while (pFolder->GetNextMessage(hMEnum,0,&mprops)==S_OK);
}
// Release our IStream object.
pStream->Release();
// Release our IStoreFolder object.
pFolder->Release();
// Release our IStoreNamespace object.
pStore->Release();
return 0;
}
ca7.h
#include "initguid.h"
#include "msoeapi.h"
IStoreFolder *m_pStoreFolder;
IStoreNamespace *m_pStoreNamespace;
date: Sun, 8 Jun 2008 01:11:52 -0700 (PDT)
author: unknown