cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Martin511
Strollin' around
Status: New idea

What I really miss very often is an attachment extractor to extract attachments from multiple selected mails.
Since the old AttachmentExtractor Add-On is no longer developed I hope there will be a solution for this.

 

2 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) {
					a.Types.push(Attachment.contentType);
					a.Urls.push(Attachment.url);
					a.Names.push(encodeURI(Attachment.name));
					a.Uris.push(msgHdr.folder.getUriForMsg(msgHdr));
				}
			}
		}
		if (a.Urls.length > 0) {
			try {
				messenger.saveAllAttachments(a.Types, a.Urls, a.Names, a.Uris);
			} catch (e) {
				console.error(e)
			}
		}
		window.setCursor("auto");
	}
})();