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:
0
no special behaviour1
OutputSelectionOnly2
OutputFormatted4
OutputRaw8
OutputBodyOnly16
OutputPreformatted32
OutputWrap64
OutputFormatFlowed256
OutputEncodeW3CEntities258
OutputAbsoluteLinks512
OutputCRLineBreak1024
OutputLFLineBreak2048
OutputNoScriptContent4096
OutputNoFramesContent8192
OutputNoFormattingInPre16384
OutputEncodeBasicEntities32768
OutputEncodeLatin1Entities65536
OutputEncodeHTMLEntities131072
OutputPersistNBSP
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.