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


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.
Posted
Updated 9-Jul-15 20:00pm
v2
Comments
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. (imap.gmail.com and stmp.gmail.com ). 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)
{
C#
CComQIPtr<Outlook::_MailItem> spNewMailitem(item);

 if (!spNewMailitem)
 {
       return;      
 }
           
		BSTR bstrBody ;

		OlBodyFormat bodyFormat;
		pMail->get_BodyFormat(&bodyFormat);


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

		if (SUCCEEDED(hr))
		{
			return CString(bstrBody);
		}
		else
		{
			_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