MozillaZine

Thunderbird macro possible?

User Help for Mozilla Thunderbird
tajkkj
 
Posts: 12
Joined: December 22nd, 2014, 3:46 pm

Post Posted September 24th, 2018, 1:18 pm

Hello, my ISP sometimes passes on e-mail they think is spam, and prepend "--SPAM--" to the subject. To inform this ISP not to consider this spam (they get a lot of false positives), I forward the e-mail to their "not spam" address. This requires several steps to start a forward composition note, and put in the not spam e-mail address. I find myself preforming this task many times a day, and it gets tiresome.

Is there a way to write a macro to do these steps, and bind it to a key so I can automate this process? Thanks.
--Tim

DanRaisch
Moderator

User avatar
 
Posts: 120453
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted September 24th, 2018, 1:45 pm


morat
 
Posts: 2906
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 24th, 2018, 2:12 pm

You can create a keyboard shortcut with the Keyconfig extension.

Keyconfig
http://addons.thunderbird.net/thunderbird/addon/602486

Code: Select all
// forward, add recipient, change subject, insert text, send now
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
  getService(Components.interfaces.nsIWindowMediator);
var msgHdr = gFolderDisplay.selectedMessage;
var listener = {
  onWindowTitleChange: function () {},
  onCloseWindow: function () {},
  onOpenWindow: function (aWindow) {
    wm.removeListener(this);
    this.compose = aWindow.docShell.
      QueryInterface(Components.interfaces.nsIInterfaceRequestor).
      getInterface(Components.interfaces.nsIDOMWindow);
    this.compose.addEventListener("compose-window-init", this, true);
  },
  handleEvent: function (event) {
    event.currentTarget.removeEventListener(event.type, this, true);
    event.currentTarget.gMsgCompose.RegisterStateListener(listener);
  },
  NotifyComposeFieldsReady: function () {},
  NotifyComposeBodyReady: function () {
    this.compose.gMsgCompose.UnregisterStateListener(this);
    this.compose.window.setTimeout(function () {
      this.AddRecipient("addr_to", "foo bar <test@invalid.com>");
      this.awDeleteRow(this.awGetMaxRecipients());
      this.GetMsgSubjectElement().value = "--SPAM-- " + this.
        GetMsgSubjectElement().value;
      this.GetCurrentEditor().insertText("Abracadabra.");
      this.goDoCommand("cmd_sendNow");
    }, 0);
  }
}
wm.addListener(listener);
MsgForwardMessage(null);

More info: viewtopic.php?p=14725693#p14725693

tajkkj
 
Posts: 12
Joined: December 22nd, 2014, 3:46 pm

Post Posted October 7th, 2018, 1:24 pm

Morat, thank you very much. That was what I was looking for.

Return to Thunderbird Support


Who is online

Users browsing this forum: No registered users and 5 guests