Send mail with several attachements with Thunderbird: Code good or improvement possible?

First I tried the copy sendmail command, but the issue is, that the subject and mail is filled with useless information. Seems to come from Windows itself.

So I wrote a new jscript button, but I'm not sure if the code is good or should be improved. But the button works like expected. :slight_smile:

Escpecially I'm wondering, why the atEnd() has always the value "0" instead of true and false.

There must be no "," at the end of the value atm. So the first idea was to add the item path and "," as long as the enumerator is not pointing to the last element and for the last element only the item path. But seems not to be possible, so I wrote a workaround (last element in the string is removed):

function OnClick(clickData) {
	var cmd = clickData.func.command;
	var tab = clickData.func.sourcetab;
	var atm = "";
	cmd.deselect = false;

	DOpus.ClearOutput();
				
		for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
			var item = e.item();
				atm += item + ",";
		}
		
	var atm2 = atm.substr(0, atm.length - 1);	
	cmd.RunCommand('thunderbird -compose "attachment=\'' + atm2 + '\'"');
}

When the code is good I can share the button. Perhaps useful for other Opus user :slight_smile:

To not forget it I add here the available command line arguments for thunderbird: Command line arguments - Thunderbird - MozillaZine Knowledge Base

2 Likes

That looks fine to me!

Re e.atEnd(), 0 and false are more or less the same thing in JScript. It'll return 1/true when it's at the end, but you'll never be at the end while inside the for-loop, since the loop stops when it's at the end.

ok. Thank you.
I thought atEnd() returns "true" when the for loop process the last item. But I understand now that it returns "true" after processing the last item and then the loop is canceled.

A script is not really needed, this command works as well:

thunderbird -compose "attachment='{allfilepath|sep=,}'"
2 Likes

thank you. In the first line I added @disablenosel:files

If I want to add the selected files to an temporary archive and send this via mail like described above I have to write a script, right?

If I do not want to use Copy ARCHIVE SENDMAIL

Yes, that would need a script if you want to do both parts from one button, without using the built-in command.