RealRaven2000 / SmartTemplates

Thunderbird Add-on: SmartTemplates
http://smarttemplates.quickfolders.org/
Other
25 stars 15 forks source link

SmartTemplates ignored when creating an email from the Thunderbird taskbar context menu #272

Closed goozak closed 6 months ago

goozak commented 8 months ago

Windows 10 / Thunderbird 115.4.1 / SmartTemplates 4.3.2

When right-clicking the Thunderbird icon on the taskbar and selecting "Write new message", the message created doesn't contain the template usually applied to new message (like when I use the "+ New Message" button above the folder list).

RealRaven2000 commented 8 months ago

Hmm, it works for me, can you export your template for the account like this:

image

If you like you can send it to me directly / off Github, maybe mention [SmartTemplates] issue 272 in the subject line.

Note that it is triggered by your email address/ identity as long as the option [x] Apply the following template to the new message is activated.

goozak commented 8 months ago

Here's the export content:

{
  "newmsg.id4": "<div style=\"font-family:'Trebuchet MS',sans-serif;font-size:10pt\">%cursor%\n</div>",
  "rspheader.id4": "",
  "rspmsg.id4": "<div style=\"font-family:'Trebuchet MS',sans-serif;font-size:10pt\">%cursor%\n</div>",
  "fwdheader.id4": "",
  "fwdmsg.id4": "<div style=\"font-family:'Trebuchet MS',sans-serif;font-size:10pt\">%cursor%\n</div>",
  "new.id4": true,
  "newhtml.id4": true,
  "newnbr.id4": true,
  "rsp.id4": true,
  "rsphead.id4": false,
  "rsphtml.id4": true,
  "rspnbr.id4": false,
  "fwd.id4": true,
  "fwdhead.id4": false,
  "fwdhtml.id4": true,
  "fwdnbr.id4": false
}

I also disabled all my other extensions, with the same result. I have two accounts set up in Thunderbird, the other one without any SmartTemplates settings. It has id5 in the json export. Not sure where id1, id2 & id3 went... The "Common" account settings in ST are empty as well.

RealRaven2000 commented 8 months ago

ok, first of all I tried to import your settings this morning, and to my surprise it didn't load them into my test profile. So there could be a separate regression in Tb115 that breaks the import, I will investigate that first. See issue #273 - I will fix this quickly and then import your settings to test them.

RealRaven2000 commented 8 months ago

After repairing the import, I am loading your template but it seems to work for me, here is the composer after loading (tested both without and with ThunderHTML Edit plugin)

image

It generates the following HTML in composer:

<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=">
  </head>
  <body smarttemplateinserted="true">
    <div id="smartTemplate4-template">
      <div style="font-family:'Trebuchet MS',sans-serif;font-size:10pt">
        <p> </p>
        <br>
      </div>
    </div>
    <p><br>
    </p>
  </body>
</html>

In Plaintext mode it generates this markup:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=">
    <style></style>
  </head>
  <body style="font-family: -moz-fixed; white-space: pre-wrap; width: 72ch;" smarttemplateinserted="true"><div
  id="smartTemplate4-template"><div style="font-family:'Trebuchet MS',sans-serif;font-size:10pt"><p> </p><br></div></div></body>
</html>

but then... I realize I haven't read your description correctly, I was using this interface:

image

You wrote something about the (Windows) taskbar... I have actually never done this, so let me look into this way of creating an email.

RealRaven2000 commented 8 months ago

So the first thing I notice here is that the "notifyComposeBodyReady" event is not fired when Thunderbird opens composer in the way you have described. this one is quite crucial for SmartTemplates to work, but it's probably not the only possible entry point for triggering its logic. You said this was working in older versions of Thunderbird (102) ?

this is going to be a little hard to debug because I cannot inspect a button that is in the Windows UI (the taskbar button) as it isn't part of the window UI of Thunderbird...

goozak commented 8 months ago

You said this was working in older versions of Thunderbird (102) ?

Not sure about that, to be honest. I don't use that context menu option often.

RealRaven2000 commented 8 months ago

OK, I found the culprit.

Apparently the window is missing some parameters that I needed to determine composeType. If it is a reply / forward composeType, I try to extract all headers from the original mail. All this data doesn't exist and the composer startup logic throws an error so SmartTemplates doesn't get to execute any of its logic.

I am not sure whether there are other ways to trigger this logic (maybe if you click on a mailto: link on a web page, this I need to investigate separately. But I think this will also trigger the "new mail" compose type, never the reply or forward. So I guess I have dealt with this problem now, by falling back to the global window.gComposeType which will tell me that it is a New email and I do not need to extract any previous headers.

smartTemplate-fx-4.3.3pre7.zip


to install the test version, download the zip file and then drag the file into Thunderbird Add-ons Manager (do not extract contents).

PS: I will close the issue myself once the next version including bugfix is released.

goozak commented 8 months ago

4.3.3pre7 works as expected. :-)

Interestingly, 'dragging into Add-ons Manager' doesn't work if the Add-ons Manager is opened via the "Add-ons and Themes" button that can be added to the Mail Toolbar... Works as expected when going thru the menu button.

RealRaven2000 commented 8 months ago

4.3.3pre7 works as expected. :-)

Interestingly, 'dragging into Add-ons Manager' doesn't work if the Add-ons Manager is opened via the "Add-ons and Themes" button that can be added to the Mail Toolbar... Works as expected when going thru the menu button.

Hmm, that worked for me - but I could only add the button to the settings tabs - I couldn't actually find the button for the "mail" space.

goozak commented 8 months ago

I couldn't actually find the button for the "mail" space.

For me, that button is in the "Available for all Spaces" section and is on all the toolbars... Weird.

RealRaven2000 commented 8 months ago

I have now also tested the case when a "mailto" link is clicked on the website - same problem here. This version fixes that by also checking the composeType for being Ci.nsIMsgCompType.MailToUrl.

smartTemplate-fx-4.3.3pre11.zip


to install the test version, download the zip file and then drag the file into Thunderbird Add-ons Manager (do not extract contents).

RealRaven2000 commented 6 months ago

Fixed in v 4.3.3 released Nov 8th.