Click here to Skip to main content
15,918,303 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I wrote add-in code for outlook. I configured my email in outlook with IMAP setting. Whenever new mail event occured I am unable to get mail body (HTML/Plain)text. It creating a problem in Put_mail() function as well. Please guide me to resolve problem

Thanks In advanced.
Updated 9-Jul-15 20:00pm
Richard MacCutchan 10-Jul-15 4:34am    
What problem, what code, what configuration? Please provide some proper details about your problem.

1 solution

Hello Richard,

This is my code. When my outlook email is configured with IMAP setting. ( and ). At that time ,bstrBody get retrieve with NULL. But (HRESULT)hr value as S_OK. So I am not getting where the problem arise. Same thing happened for put_mail() function.

void CAdIn::OnNewItemSEH(IDispatch * item)
CComQIPtr<Outlook::_MailItem> spNewMailitem(item);

 if (!spNewMailitem)
		BSTR bstrBody ;

		OlBodyFormat bodyFormat;

		if (bodyFormat == olFormatHTML)
			hr = pMail->get_HTMLBody(&bstrBody);
			hr = pMail->get_Body(&bstrBody);

		if (SUCCEEDED(hr))
			return CString(bstrBody);
			_com_error err(hr);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900