Hi,
Hi,
I am using the Exchange Plugin from It2Be ( b.t.w. nice plugin !!) to interact with exchange 2010.
When I get the body from a mail it can have markup ( html / rtf / word /??)
is there a way to get the plain text from it ?
Regards,
var htmlEditorKit = new Packages.javax.swing.text.html.HTMLEditorKit();
var htmlDocument = htmlEditorKit.createDefaultDocument();
var reader = new java.io.StringReader('myHtmlTextString');
htmlEditorKit.read(reader, htmlDocument, 0);
var result = htmlDocument.getText(0, htmlDocument.getLength());
return utils.stringTrim(result));
myMailObject.bodyType = plugins.it2be_exchangews.type.js_getBody_TEXT();
var _plainText = myMailObject.body;
replace(/<[a-zA-Z\/][^>]*>/g,'').replace(/&[^;]+?;/g,'')
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
l xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:off
ice:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://sche
mas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
undefined
undefined
undefined
undefinedundefinedv\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
undefinedundefinedundefinedundefinedundefinedundefinedundefined
undefined
undefinedundefinedundefinedundefined
undefined
undefined
var htmlEditorKit = new Packages.javax.swing.text.html.HTMLEditorKit();
var htmlDocument = htmlEditorKit.createDefaultDocument();
htmlDocument.putProperty("IgnoreCharsetDirective", true);
var reader = new java.io.StringReader(_mail.body);
htmlEditorKit.read(reader, htmlDocument, 0);
var result = htmlDocument.getText(0, htmlDocument.getLength());
_noHtml = utils.stringTrim(result);
Users browsing this forum: No registered users and 8 guests