A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How we can find out the format of the mail.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 13th 06, 09:59 AM posted to microsoft.public.outlook.program_addins
Vinayakc
external usenet poster
 
Posts: 22
Default How we can find out the format of the mail.

Hi all,

I have written one Outlook add-in in C++. I want to detect the mail
format of the mail through that add-in. ( RTF,HTML or Plain Text ).
I have tried to do some search on this, I only got that, thorugh VBA we
can use BodyFormat property of the mail item. How I can access this
property through my C++ code?

If Outlook is able to detect the format of incoming mail, I think we
should also able to detect the format? Are there any MAPI properties
which we can use for this?

Through OutllookSpy when I look the properties of that mail item, I
observerd that
1. HTML and RTF mails have PR_RTF_COMPRESSED property.
2. Plain text does not have PR_RTF_COMPRESSED property.
3. RTF mails have useTNEF property value as True and HTML mails have
useTNEF property value as False.

Will this observation help us??

Please reply as soon as possible.

Thanks and Regards
Vinayakc

  #2  
Old January 15th 06, 11:45 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How we can find out the format of the mail.

Read the RTFBody property and check if "\fromhtml1" is in the first 100
bytes or so: if yes, you have HTML. If you have "\fromtext" - it is text.
Otherwise it is pure RTF.
If RTF is missing, check if PR_HTML_BODY or PR_HTML is present.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Vinayakc" wrote in message
ups.com...
Hi all,

I have written one Outlook add-in in C++. I want to detect the mail
format of the mail through that add-in. ( RTF,HTML or Plain Text ).
I have tried to do some search on this, I only got that, thorugh VBA we
can use BodyFormat property of the mail item. How I can access this
property through my C++ code?

If Outlook is able to detect the format of incoming mail, I think we
should also able to detect the format? Are there any MAPI properties
which we can use for this?

Through OutllookSpy when I look the properties of that mail item, I
observerd that
1. HTML and RTF mails have PR_RTF_COMPRESSED property.
2. Plain text does not have PR_RTF_COMPRESSED property.
3. RTF mails have useTNEF property value as True and HTML mails have
useTNEF property value as False.

Will this observation help us??

Please reply as soon as possible.

Thanks and Regards
Vinayakc



  #3  
Old January 17th 06, 11:28 AM posted to microsoft.public.outlook.program_addins
Vinayakc
external usenet poster
 
Posts: 22
Default How we can find out the format of the mail.

Hi Dmitry,

Thanks for your reply.
I have searched for how to access the "RTFBody" property of the mail
item. But I could not get anything on that.
I want to use Outlook object model and MAPI propertries only.
I am not using Redemption.

Thanks and Regards
Vinayakc.

  #4  
Old January 17th 06, 06:59 PM posted to microsoft.public.outlook.program_addins
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default How we can find out the format of the mail.

Open the PR_RTF_COMPRESSED property from IMessage as IStream and uncompress
it using WrapCompressedRtfStream function.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Vinayakc" wrote in message
oups.com...
Hi Dmitry,

Thanks for your reply.
I have searched for how to access the "RTFBody" property of the mail
item. But I could not get anything on that.
I want to use Outlook object model and MAPI propertries only.
I am not using Redemption.

Thanks and Regards
Vinayakc.



  #5  
Old January 20th 06, 08:13 AM posted to microsoft.public.outlook.program_addins
Vinayakc
external usenet poster
 
Posts: 22
Default How we can find out the format of the mail.

Hi Dmitry,

Thanks, thank you very much for great help.

This solved my problem.

I got one good article at :
http://support.microsoft.com/?id=839560

Thanks again,
Vinayak

  #6  
Old January 27th 06, 02:51 PM posted to microsoft.public.outlook.program_addins
Vinayakc
external usenet poster
 
Posts: 22
Default How we can find out the format of the mail.

My code for other's reference :

BOOL CheckHTML(CComPtrIMessage pMsg, BOOL* bHtml)
{
HRESULT hr = S_OK;
LPSTREAM lpCompressed = NULL;
LPSTREAM lpUncompressed = NULL;
BOOL bRet = TRUE;
BYTE htmlbuf[UNCOMPRESSED_RTF_BUFFER_MAX_SIZE] = {0};
try
{
hr = pMsg-OpenProperty(PR_RTF_COMPRESSED,
&IID_IStream,
STGM_READ,
0,
(LPUNKNOWN*)&lpCompressed);
if( hr!= S_OK )
{
LOG_ERR_MESSAGE(_T("OpenProperty(): error while opening property
PR_RTF_COMPRESSED. ") , hr);
bRet = FALSE;
goto Error;
}

hr = WrapCompressedRTFStream(lpCompressed,
0,
&lpUncompressed
);

if( hr!= S_OK )
{
LOG_ERR_MESSAGE(_T("WrapCompressedRTFStream(): error while reading
uncompressed property PR_RTF_COMPRESSED. ") , hr);
bRet = FALSE;
goto Error;
}
ULONG red;
hr = lpUncompressed-Read(htmlbuf, UNCOMPRESSED_RTF_BUFFER_MAX_SIZE -
1, &red);
if( lpUncompressed )
lpUncompressed-Release();
if( lpCompressed )
lpCompressed-Release();
htmlbuf[UNCOMPRESSED_RTF_BUFFER_MAX_SIZE]=0;
if( htmlbuf != 0)
{
// We look for the words "\fromhtml1" somewhere in the uncompressed
RTF body
// If it contains "\fromhtml1" then we assume message format as
HTML
if( strstr( (const char*) htmlbuf, "\\fromhtml1" ) != NULL)
{
*bHtml = TRUE;
}
else
{
*bHtml = FALSE;
}
}
goto End;
}
catch(...)
{
LOG_ERR_MESSAGE(_T("Exception Generated") , GetLastError());
REPORT_SYSTEM_ERROR_TO_IRONPORT_HTTP(_T("Exception Generated"));
bRet = FALSE;
goto Error;
}
End:
Error:
return bRet;
}

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to save a contact in SMTP format not exchange format. JAX Outlook - Using Contacts 0 February 15th 06 02:51 PM
Why do i receive calendar notes in an e-mail format? Admin210 Outlook - Calandaring 3 February 9th 06 02:25 PM
how do i find type of mail opened? Sue Mosher [MVP-Outlook] Outlook - Using Forms 0 February 6th 06 09:13 PM
How to determine the format for each e-mail in Outlook 2000? Uncle Bill Outlook - Using Contacts 0 February 1st 06 10:46 PM
Choosing OptionsMail Format Crashes Outlook 2003 Baer Bradford Outlook - Installation 2 January 13th 06 06:36 AM


All times are GMT +1. The time now is 08:49 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.