This is a kind of follow-up of the following question/answer: https://stackoverflow.com/a/60246205/6342243
The code at the end of this question gets a list of accounts, selects the emailAccountName
, gets a MessageList object from the wantedMailFolderType
and tries to get a MessagePart object from just one single messageId via browser.messages.getFull( messageId ) which always fails with the following Exception message:
[Exception...
"Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
[nsIMsgMessageService.streamMessage]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: resource:///modules/gloda/mimemsg.js
:: MsgHdrToMimeMessage
:: line 238" data: no]
mimemsg.js:238:16
This behaviour is the same on linux mint 19.3 (64-Bit) running thunderbird 68.4.1 (64-Bit) as well as on windows 7 (64-Bit) running thunderbird 68.2.2 (32-Bit).
Here the code which reproduces the error:
emailAccountName = "firstname.lastname@email.com";
wantedMailFolderType = "trash";
console.log( tstamp() + " Entered Main Program" );
function tstamp () {
let d =new Date();
return "" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
}
function accountsList_successCallback( arrayOfMailAccount ) {
console.log( tstamp() + " Entered accountsList_successCallback()" );
let accountId = false;
for (let i = 0; i < arrayOfMailAccount.length; i++) {
if ( arrayOfMailAccount[i].name == emailAccountName ) {
accountId = arrayOfMailAccount[i].id;
break;
}
}
console.log( tstamp() + " Leaving accountsList_successCallback(), returning accountId: " + accountId );
return accountId;
}
function mailAccount_successCallback( mailAccount ) {
console.log( tstamp() + " Entered mailAccount_successCallback()" );
let mailFolder = false;
for (let i = 0; i < mailAccount.folders.length; i++) {
if ( mailAccount.folders[i].type == wantedMailFolderType ) {
mailFolder = mailAccount.folders[i];
break;
}
}
console.log( tstamp() + " Leaving mailAccount_successCallback(), returning mailFolder: " + mailFolder.type );
return mailFolder;
}
async function getMessagesList( mailFolder ) {
console.log( tstamp() + " Entered getMessagesList()" );
let page = await browser.messages.list( mailFolder );
let messageHeader = page.messages[ 0 ];
let messageId = messageHeader.id;
console.log( `Trying to .getFull( messageId == ${messageId} ) MessagePart object now...` );
let messagePart = await browser.messages.getFull( messageId );
console.log( tstamp() + " Leaving getMessagesList()" );
}
browser.accounts.list()
.then( accountsList_successCallback) // after .accounts.list() Promise is fulfilled...
// accountsList_successCallback is called, which
// in this example returns the accountId string...
.then( accountId => browser.accounts.get( accountId ))
.then( mailAccount_successCallback) // after .accounts.get() Promise is fulfilled...
// mailAccount_successCallback is called, which
// returns the wanted MailFolder...
.then( getMessagesList ) // ... passed to getMessagesList(), which successfully
// awaits a MessageList object...
// but every call to .getFull( messageId ) fails.
.catch( finalCatch )
;
function finalCatch( error ) {
console.error( "ERROR passed to finalCatch() : " + error);
}
console.log( tstamp() + " Leaving Main Program" );
This was the output of the last run (line-numbers in popup.js xx-ed out, because they do not match with this extract):
52:40.859 Entered Main Program popup.js:xx:9
52:40.874 Leaving Main Program popup.js:xx:9
52:40.964 Entered accountsList_successCallback() popup.js:xx:13
52:40.964 Leaving accountsList_successCallback(), returning accountId: account26 popup.js:xx:13
52:40.988 Entered mailAccount_successCallback() popup.js:xx:13
52:40.989 Leaving mailAccount_successCallback(), returning mailFolder: trash popup.js:xx:13
52:40.989 Entered getMessagesList() popup.js:xx:13
Trying to .getFull( messageId == 1 ) MessagePart object now... popup.js:xx:13
[Exception...
"Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
[nsIMsgMessageService.streamMessage]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)"
location: "JS frame :: resource:///modules/gloda/mimemsg.js
:: MsgHdrToMimeMessage
:: line 238" data: no]
mimemsg.js:238:16
ERROR passed to finalCatch() : Error: An unexpected error occurred popup.js:xx:13
Could anyone please try this out on his machine? How to proceed further? Should a bug on BugZilla be reportet?
Thanks in advance. richard