cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Soundlabmedia
New member
Status: New idea

From time to time I have to clean up disk space by deleting hundreds of old (and large) attachments
from many mails, while keeping the mails themselves for documentation purposes.
I would find it very helpful, if there was a possibility to select multiple mails
and to be able to delete their attachments all at once with one command
instead of having to delete the attachments of each mail seperately.

I know that there had been a plugin for this, but it's outdated and does not work
with actual thunderbird versions...

7 Comments
Status changed to: New idea
Jon
Community Manager
Community Manager

Thanks for submitting an idea to the Mozilla Connect community! Your idea is now open to votes (aka kudos) and comments.

Awako
Making moves
(async () => {	
	const { MsgHdrToMimeMessage } = ChromeUtils.import("resource:///modules/gloda/MimeMessage.jsm");
	let getAttachments = async function(MsgHdr, resolve = null) {
		return new Promise(resolve => {
				MsgHdrToMimeMessage(MsgHdr, null, (_msgHdr, mimeMsg) => {
					resolve(mimeMsg.allUserAttachments);
				}, true, { examineEncryptedParts: true, partsOnDemand: true })
			})
	}
	let msgHdrs = gFolderDisplay.selectedMessages;
	if (msgHdrs.length > 0) {
		window.setCursor("wait");
		let a = {Types: [], Urls: [], Names: [], Uris: []};
		for (let msgHdr of msgHdrs) {
			if (msgHdr.flags & Ci.nsMsgMessageFlags.Attachment) {
				let allAttachments = await getAttachments(msgHdr);
				for (let Attachment of allAttachments) {
					messenger.detachAttachment(
						Attachment.contentType,
						Attachment.url,
						encodeURIComponent(Attachment.name),
						msgHdr.folder.getUriForMsg(msgHdr),
						false, [false])
				}
			}
		}
		window.setCursor("auto");
	}
})();
MattAuSupport
Familiar face
Soundlabmedia
New member

@MattAuSupport 
Thanks, for the info, but that's the version which does't work
any longer on actual versions of Thunderbird.

Soundlabmedia
New member

Thanks for the info, but the addon is outdated and doesn't work with the actual version of thunderbird...

rclerc
New member

@Awako, could you please explain how we are supposed to use this code to implement this functionnality ? 

Awako
Making moves
you need add in Thunderbird the context menu button, and copy this code in event "click"
 
or, make my wish come true by adding the ability to create your own buttons in Thunderbird