MozillaZine


Saving a single message with the date info

User Help for Mozilla Thunderbird
user2018
 
Posts: 88
Joined: September 23rd, 2018, 11:07 am

Post Posted November 11th, 2020, 4:16 am

When you select several email messages in Thunderbird and use the "Save as file" option, the filename format includes date info. However, if you select a single message and do the same then the date info is not included. So the filename format does not seem to be consistent (it changes depending on whether a single or multiple messages are selected); e.g., if I save the files selecting messages A and B and then I save only A and then I save only B then I get 4 files (instead, I think that only 2 files should be obtained and a confirmation dialog regarding the overwriting should be shown).

Summing up, I would like the filename format to be the same whether a single or several messages are selected and this filename format should include the timestamp information. Any advice about how this can be done? (I know about the extension ImportExport Tools, but it does not work in the recent versions of Thunderbird; besides, this seems to be a simple functionality to get, as it already works when several messages are selected; maybe some preference is available for this?).

Any advice or idea is welcome.

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

Post Posted November 11th, 2020, 8:47 am

You can't change the format with a preference.

Reference
http://searchfox.org/comm-esr78/search?q=function+SaveAsFile&path=mailCommands.js

user2018
 
Posts: 88
Joined: September 23rd, 2018, 11:07 am

Post Posted November 11th, 2020, 10:13 am

Thank you very much for the link. The modification needed for this to work seems pretty simple. Is there any easy way of overriding the definition of the function without modifying the original code?

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

Post Posted November 11th, 2020, 10:43 am

You can reassign the SaveAsFile function with another function or use eval. I guess...

Find:

Code: Select all
let name = msgHdr.mime2DecodedSubject;

Replace with:

Code: Select all
let name = GenerateFilenameFromMsgHdr(msgHdr);

Examples
viewtopic.php?p=14802871#p14802871
viewtopic.php?p=14875202#p14875202
viewtopic.php?p=14869120#p14869120

sfhowes
 
Posts: 586
Joined: April 1st, 2012, 10:21 am

Post Posted November 11th, 2020, 11:42 am

ImportExportTools NG for TB 68 & 78:

https://addons.thunderbird.net/en-US/th ... ttools-ng/

File naming settings in the add-on's Options.

user2018
 
Posts: 88
Joined: September 23rd, 2018, 11:07 am

Post Posted November 13th, 2020, 4:56 am

Thanks a lot! Both options seem to work perfectly.

user2018
 
Posts: 88
Joined: September 23rd, 2018, 11:07 am

Post Posted January 12th, 2021, 5:01 am

I noticed a problem with the solution based on reassigning the SaveAsFile function. I use this code:

Code: Select all
     
      var a = "let name = msgHdr.mime2DecodedSubject;";
      var b = "let name = GenerateFilenameFromMsgHdr(msgHdr);";
      eval("SaveAsFile = " + SaveAsFile.toString().
        replace(a, b));


But when I store a message with subject "RE: Fwd: Re: My message", the message is stored as "Re_ Re_ Fwd_ Re_ My message....eml", that is, an extra "Re" is added, which is confusing and not appropritate. Any idea about the reason and how to solve it?

Thank you.

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

Post Posted January 12th, 2021, 8:52 am

Try this:

Code: Select all
/* Thunderbird userChrome.js */

(function () {

if (location == "chrome://messenger/content/messenger.xul" ||
    location == "chrome://messenger/content/messenger.xhtml") {

  var a = "    let name = msgHdr.mime2DecodedSubject;"           + "\n";
  a = a + "    if (msgHdr.flags & Ci.nsMsgMessageFlags.HasRe) {" + "\n";
  a = a + '      name = name ? "Re: " + name : "Re: ";'          + "\n";
  a = a + "    }"                                                + "\n";
  var b = "    let name = GenerateFilenameFromMsgHdr(msgHdr);"   + "\n";
  eval("SaveAsFile = " + SaveAsFile.toString().
    replace(a, b));

}

})();

user2018
 
Posts: 88
Joined: September 23rd, 2018, 11:07 am

Post Posted January 13th, 2021, 1:06 am

Thank you very much for the proposal!

Is the solution proposed a "hack" to fix a bug in mime2DecodedSubject? I ask this because it seems to me that the string returned by mime2DecodedSubject should be the one I was expecting, although I may be mistaken.

I tried it and this solves the problem mentioned. However, if the subject is actually something like "Re: Re: ..." (I'm not sure if receiving messages with such a subject makes sense or not -?-, but I do sometimes) then when I try to save the file only one of the "Re" is kept (however, in this case, the double "Re" is legitimate).

Another related strange behavior that I'm not sure if it is correct. If I forward a message such as "Re: ..." then the subject considered by Thunderbird for the new message to be forwarded is "Fwd: ..." (the "Re:" is lost): shouldn't it be "Fwd: Re: ..."? With further testing, I realize that something similar also happens if the subject is "Re: Fwd:": it gets transformed to "Fwd: Fwd:" when forwarded. Maybe all this is intended behavior, but I find it a bit strange.

Thank you for any suggestion.

Return to Thunderbird Support


Who is online

Users browsing this forum: DanRaisch, Google Adsense [Bot] and 7 guests