Click here to Skip to main content
15,896,606 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DeviceIoControl Pin
Waldermort9-Sep-07 20:14
Waldermort9-Sep-07 20:14 
GeneralRe: DeviceIoControl Pin
Nishad S9-Sep-07 20:30
Nishad S9-Sep-07 20:30 
GeneralRe: DeviceIoControl Pin
Waldermort9-Sep-07 20:34
Waldermort9-Sep-07 20:34 
QuestionSOLVED Missing browse info in VC 6.0 [modified] Pin
Vaclav_9-Sep-07 17:06
Vaclav_9-Sep-07 17:06 
AnswerRe: Missing browse info in VC 6.0 Pin
ThatsAlok9-Sep-07 18:46
ThatsAlok9-Sep-07 18:46 
GeneralRe: Missing browse info in VC 6.0 Pin
Vaclav_9-Sep-07 20:32
Vaclav_9-Sep-07 20:32 
GeneralRe: Missing browse info in VC 6.0 Pin
ThatsAlok10-Sep-07 2:17
ThatsAlok10-Sep-07 2:17 
QuestionStart Topic Pin
monsieur_jj9-Sep-07 15:02
monsieur_jj9-Sep-07 15:02 
Hi all,

I am developing a snippet for extraction of msg propeties, I am using
outlook 2003. Now my problem is the current mapi_utils does not
extract the PR_HTML body which I need to show the embedded files in
the body and the right format of the body as well.

What I exactly need is the HTML format of the .msg file.

The current mapi_utils are only applicable upto outlook 2000.

Please help me

Thank you,
Jj

the code:

//purpose: resolve the msg file to have the message class
	//
	HRESULT hResult;		
	WORD          wKey = 0; 	
	LARGE_INTEGER liZero = { 0 }; 
	LPSTREAM      pTNEFStream = NULL; 
	LPITNEF       pTNEFObj = NULL; 	

	
	MAPIINIT_0 MInit;	
	MInit.ulVersion = MAPI_INIT_VERSION;
	MInit.ulFlags = 0;

	hResult = MAPIInitialize(NULL);	

	if (hResult !=S_OK){ 			
		throw(HResultException("MapiInit ResolveMsg",0));						
	 }    
	IMalloc *m_pMalloc;	
	hResult = CoGetMalloc(1, &m_pMalloc);
	
	if (hResult !=S_OK){ 			
		throw(HResultException("CoMalloc ResolveMsg",0));						
	}		
	
	IStorage *pStorage = NULL;
	LPMSGSESS pMsgSession =  NULL;
	LPMESSAGE pIMsg = NULL;
	
	hResult = ::StgOpenStorageEx(_bstr_t(msgName.c_str()),STGM_READWRITE |STGM_TRANSACTED ,STGFMT_DOCFILE ,0,
		NULL, NULL, IID_IStorage,(void**)&pStorage);

	if (hResult !=S_OK){ 			 		
		throw(HResultException("stgStorage ResolveMsg",0));						
	 }
	if (pStorage==NULL) 
		throw(HResultException("stgStorageNull ResolveMsg",0));						
	
	hResult = ::OpenIMsgSession(m_pMalloc, 0, &pMsgSession);	
	if (hResult !=S_OK){ 			 		
		throw(HResultException("OpenImsgSession ResolveMsg",0));						
	 }	
	hResult = ::OpenIMsgOnIStg(pMsgSession,MAPIAllocateBuffer,MAPIAllocateMore,MAPIFreeBuffer,m_pMalloc,0,
							pStorage,0, 0, 0, &pIMsg);  

	if (hResult !=S_OK){ 			 		
		throw(HResultException("OpenIMsgOnIStg ResolveMsg",0));
	 }

	hResult = WriteClassStg(pStorage, CLSID_MailMessage);

	if (hResult !=S_OK){ 			 		
		throw(HResultException("WriteClassStg ResolveMsg",0));
	 }	

	HRESULT hrProperty;		
	LPSPropValue lpPropValue = NULL;

	hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg,PR_MESSAGE_CLASS ,&lpPropValue);	

	if (hrProperty != S_OK){ 
		
		loopMsg(pIMsg,pStorage);

		hResult = pIMsg->SaveChanges (KEEP_OPEN_READWRITE);	
		
		if (hResult !=S_OK){ 			 			
			throw(HResultException("pIMsg->SaveChanges ResolveMsg",hResult));						
		 }

		hResult = pStorage->Commit(STGC_DEFAULT);

		if (hResult !=S_OK){ 			 			
			throw(HResultException("Commit of HTML failed in redmap::MailFile::decodeTnef", hResult));
		}	
	}

	////additional by jdeguzman	
	
	hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg, PR_BODY_HTML, &lpPropValue);
	hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg, PR_HTML, &lpPropValue);
	CBase64* baseconvert = new CBase64;
	//baseconvert->Decode(
	if (hrProperty != S_OK) 
	{		 
		hrProperty = HrGetOneProp((LPMAPIPROP)pIMsg, PR_BODY_HTML_B, &lpPropValue);		
		if (hrProperty == S_OK){
			CString text;
			text.GetBufferSetLength(lpPropValue[0].Value.bin.cb + 1);
			text.SetString((LPCSTR)lpPropValue[0].Value.bin.lpb,lpPropValue[0].Value.bin.cb);		
		
			enum {BODY, MSG_ADDPROPS };		
			SPropValue lpPropValueArray2[MSG_ADDPROPS];

			lpPropValueArray2[BODY].ulPropTag = PR_BODY_HTML;			
			lpPropValueArray2[BODY].Value.lpszA = (LPSTR)text.GetString();
		
			hResult =  pIMsg->SetProps(MSG_ADDPROPS, lpPropValueArray2,NULL);	
			if (hResult !=S_OK){ 			 
				throw(HResultException("SetProps of HTML failed in redmap::MailFile::decodeTnef", hResult));								
			}

			hResult = pIMsg->SaveChanges (KEEP_OPEN_READWRITE);   
			if (hResult !=S_OK){ 			 
				throw(HResultException("SaveChanges of HTML failed in redmap::MailFile::decodeTnef", hResult));
			}

			hResult = pStorage->Commit(STGC_DEFAULT);
			if (hResult !=S_OK){ 			 
				throw(HResultException("Commit of HTML failed in redmap::MailFile::decodeTnef", hResult));			
			}
			if (lpPropValue) MAPIFreeBuffer(lpPropValue);			
		}
	}

	pIMsg->Release();
	pIMsg = NULL;	
	CloseIMsgSession ( pMsgSession );
	pMsgSession =  NULL;  
	
	pStorage->Release();
	pStorage=NULL;	

	::MAPIUninitialize();  

	
	return 1;

QuestionLINK : fatal error LNK1561: entry point must be defined?? [modified] Pin
ashokbngr9-Sep-07 14:48
ashokbngr9-Sep-07 14:48 
AnswerRe: LINK : fatal error LNK1561: entry point must be defined?? Pin
Mark Salsbery9-Sep-07 16:09
Mark Salsbery9-Sep-07 16:09 
QuestionStrange exception error while debugging Pin
minike9-Sep-07 14:05
minike9-Sep-07 14:05 
AnswerRe: Strange exception error while debugging Pin
Mark Salsbery9-Sep-07 14:16
Mark Salsbery9-Sep-07 14:16 
GeneralRe: Strange exception error while debugging Pin
minike9-Sep-07 14:41
minike9-Sep-07 14:41 
AnswerRe: Strange exception error while debugging Pin
Stephen Hewitt9-Sep-07 17:20
Stephen Hewitt9-Sep-07 17:20 
QuestionDDX_Text in Visual C++ 7.1 Pin
bob169729-Sep-07 11:52
bob169729-Sep-07 11:52 
AnswerRe: DDX_Text in Visual C++ 7.1 Pin
bob1697210-Sep-07 3:56
bob1697210-Sep-07 3:56 
QuestionNew to programming Pin
shortstuff559-Sep-07 11:42
shortstuff559-Sep-07 11:42 
AnswerRe: New to programming Pin
Michael Dunn9-Sep-07 12:18
sitebuilderMichael Dunn9-Sep-07 12:18 
AnswerRe: New to programming Pin
david bagaturia9-Sep-07 20:09
david bagaturia9-Sep-07 20:09 
AnswerRe: New to programming Pin
Hamid_RT9-Sep-07 23:23
Hamid_RT9-Sep-07 23:23 
AnswerRe: New to programming Pin
David Crow10-Sep-07 5:55
David Crow10-Sep-07 5:55 
QuestionProcessing WM_MEASUREITEM message Pin
taliadon9-Sep-07 11:28
taliadon9-Sep-07 11:28 
AnswerRe: Processing WM_MEASUREITEM message Pin
Michael Dunn9-Sep-07 12:23
sitebuilderMichael Dunn9-Sep-07 12:23 
QuestionCString question Pin
locoone9-Sep-07 10:08
locoone9-Sep-07 10:08 
AnswerRe: CString question Pin
Vaclav_9-Sep-07 17:14
Vaclav_9-Sep-07 17:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.