-
Notifications
You must be signed in to change notification settings - Fork 58
Script: GetMailBody
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.
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 behaviour -
1OutputSelectionOnly -
2OutputFormatted -
4OutputRaw -
8OutputBodyOnly -
16OutputPreformatted -
32OutputWrap -
64OutputFormatFlowed -
256OutputEncodeW3CEntities -
258OutputAbsoluteLinks -
512OutputCRLineBreak -
1024OutputLFLineBreak -
2048OutputNoScriptContent -
4096OutputNoFramesContent -
8192OutputNoFormattingInPre -
16384OutputEncodeBasicEntities -
32768OutputEncodeLatin1Entities -
65536OutputEncodeHTMLEntities -
131072OutputPersistNBSP
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 wishAn example for use with schleuder mailing list is explain here: Script: SchleuderResend.