Script: GetMailBody - jobisoft/quicktext GitHub Wiki
Sometimes, you want to perform action based on some item(s) present(s) in the body of the mail. For now, Quicktext has no shortcut to access it. Here is a short script that return you the body in plaintext or html format. It is also possible to return only the current selection.
Script
GetMailBody
var editor = this.mWindow.gMsgCompose.editor;
var text = editor.outputToString('text/plain', 0);
return text;
The two parameters formatType = 'text/plain' and flags = 0 of the function outputToString can be tweaked like documented here. For example using the following line would return the current selection as html:
var text = editor.outputToString('text/html', 1);
First parameter formatType:
'text/plain'return unformatted content (text)'text/html'return formatted content (html)
Second parameter flags can be combined (for example 1 + 8 = 9) from the following values:
0no special behaviour1OutputSelectionOnly2OutputFormatted4OutputRaw8OutputBodyOnly16OutputPreformatted32OutputWrap64OutputFormatFlowed256OutputEncodeW3CEntities258OutputAbsoluteLinks512OutputCRLineBreak1024OutputLFLineBreak2048OutputNoScriptContent4096OutputNoFramesContent8192OutputNoFormattingInPre16384OutputEncodeBasicEntities32768OutputEncodeLatin1Entities65536OutputEncodeHTMLEntities131072OutputPersistNBSP
Usage
Then, you can now use it to retrieve the body text in any other script:
MyWonderfulScript
text = await this.mQuicktext.get_script(["GetMailBody"])
//process the text string as you wish
An example for use with schleuder mailing list is explain here: Script: SchleuderResend.