Jens Hatlak wrote:
Rick Merrill wrote:
Say I have a list of 120 emails - how would I print out
that list of "subject" (not the content)?
The proper way to do this is to access the list the same way SM does
internally - using JavaScript. There may be add-ons that already provide
that functionality, but since I already programmed this functionality
for myself years ago, I'll just share it with you. I thought I had
already added it to my Custom Buttons page [1], but obviously I haven't
(yet). Seems my todo list never stops growing...
[1]: <http://jens.hatlak.de/en/mozilla/buttons/index.php4>
Anyway, in order to make use of the below, install the Custom Buttons
add-on first, then create a new Custom Button in MailNews by
right-clicking a MailNews toolbar and choosing Add Button (not sure
whether that's the exact label in English, I'm having a German SM here),
copy the code below into the textarea on the first tab of the dialog,
press OK, and then use Customize from a MailNews toolbar's context menu
to finally add the newly created button.
After that you can of course try and modify the code, e.g. in order to
avoid the <br>s if all you need is plain text as output.
---------------
function getSubjectFromMsgHdr(aMsgHdr) {
if (aMsgHdr.mime2DecodedSubject)
return aMsgHdr.mime2DecodedSubject;
return aMsgHdr.subject;
}
function copyHTMLToClipboard(aHTMLText) {
let strlen = aHTMLText.length * 2;
let str = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
if (!str)
return false;
str.data = aHTMLText;
var trans = Components.classes["@mozilla.org/widget/transferable;1"]
.createInstance(Components.interfaces.nsITransferable);
if (!trans)
return false;
trans.addDataFlavor("text/unicode");
trans.setTransferData("text/unicode", str, strlen);
trans.addDataFlavor("text/html");
trans.setTransferData("text/html", str, strlen);
var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
.getService(Components.interfaces.nsIClipboard);
if (!clipboard)
return false;
clipboard.setData(trans, null,
Components.interfaces.nsIClipboard.kGlobalClipboard);
return true;
}
let html = "";
let msgs = gFolderDisplay.selectedMessages;
for (let i = 0; i < msgs.length; ++i) {
let subject = getSubjectFromMsgHdr(msgs[i]);
html += subject + "<br>\n";
}
copyHTMLToClipboard(html);
---------------
HTH
Jens
Hmmm . . . Thought Java was dangerous, and that's why SM won't let us
use it without going through contortions?
Larry S.
_______________________________________________
support-seamonkey mailing list
[email protected]
https://lists.mozilla.org/listinfo/support-seamonkey