-
Notifications
You must be signed in to change notification settings - Fork 58
Script: GetLinepart
SamuelPlentz edited this page Jul 2, 2022
·
1 revision
When replying to another mail, get lineparts of that other mail, for example fields of a form.
let prefix = this.mVariables[0];
let suffix = this.mVariables[1];
var editor = this.mWindow.gMsgCompose.editor;
var text = editor.outputToString('text/plain', 0);
var result = text.match(prefix + "(.*)" + suffix);
if(result != null) return result[1];
return '';Consider the following two mails you are replying to:
Form about customer satisfaction
Name: John Doe
City: Berlin
Satisfaction level: 5 Stars
2022-07-02 Form by SunnyTech
Form about customer satisfaction
Name: Jane Doe
City: London
Satisfaction level: 1 Star
2022-06-31 Form by SunnyTech
Search for a line with the prefix Name: and no suffix (will find John Doe and Jane Doe):
[[SCRIPT=GetLinepart|Name: ]]
Search for a line with the prefix City: and no suffix (will find Berlin and London):
[[SCRIPT=GetLinepart|City: ]]
Search for a line with the prefix Satisfaction level: and the suffix Star (will find 5 and 1):
[[SCRIPT=GetLinepart|Satisfaction level: | Star]]
Search for a line with no prefix and the suffix Form by SunnyTech (will find 2022-07-02 and 2022-06-31):
[[SCRIPT=GetLinepart|| Form by SunnyTech]]