Search code examples
javascriptthunderbird-addonthunderbird-webextensions

Send mail with Thunderbird MailExtension


Is it possible for a Thunderbird Add-On to send a message that it initiated by compose.beginReply?

I added a message_display_button in manifest.json. The following is the background-script, which opens a reply after clicking that button, adds some text to the body and then it should finish by sending the mail:

browser.messageDisplayAction.onClicked.addListener(async (tab) => {
    browser.messageDisplay.getDisplayedMessage(tab.id).then(async (message) => {
        let mailTab = await browser.compose.beginReply(message.id);
        let details = await browser.compose.getComposeDetails(mailTab.id);
        //... manipulate html
        browser.compose.setComposeDetails(mailTab.id, {body: html});
        // now send... but how?
    });
});

I could not find a function for sending a composed message in the WebExtension documentation https://webextension-api.thunderbird.net/en/latest/compose.html#functions


Solution

  • await browser.compose.sendMessage(mailTab.id,{mode:'sendNow'})
    

    you can check the latest documentation https://webextension-api.thunderbird.net/en/91/compose.html also it needs permission compose.send