I used this example of the stable documentation
let attachments = await browser.messages.listAttachments(messageId);
for (let att of attachments) {
let file = await browser.messages.getAttachmentFile(
messageId,
att.partName
);
let content = await file.text();
}
It doesn't work.
https://webextension-api.thunderbird.net/en/stable/messages.html
My other source code in the background.js of my extension
async function mail_display(tab, message) {
console.log(`Message displayed in tab ${message.messageId}: ${message.subject}`);
console.log(message.id);
try {
let attachments = await browser.messages.listAttachments(message.id);
console.log(attachments);
for (let att of attachments) {
let file = await browser.messages.getAttachmentFile(messageId, att.partName);
console.log(file);
let content = await file.text();
}
} catch(error) {
console.log(`Fehler beim Abrufen der Attachments: ${error}`);
}
}
browser.messageDisplay.onMessageDisplayed.addListener(mail_display);
It returns an empty array with no attachment.
okay i found a solution that is working:
Note: