messages¶
The messages API first appeared in Thunderbird 66.
Note
When the term messageId is used in these documents, it doesn’t refer to the Message-ID
email header. It is an internal tracking number that does not remain after a restart. Nor does
it follow an email that has been moved to a different folder.
Warning
Some functions in this API potentially return a lot of messages. Be careful what you wish for! See Working with Message Lists for more information.
Permissions¶
Functions¶
list(folder)¶
continueList(messageListId)¶
Returns the next chunk of messages in a list. See Working with Message Lists for more information.
messageListIdget(messageId)¶
Returns a specified message.
messageIdgetFull(messageId)¶
Returns a specified message, including all headers and MIME parts.
messageIdgetRaw(messageId)¶
Returns the unmodified source of a message as a binary string.
messageIdlistAttachments(messageId)¶
Lists all of the attachments of a message.
messageIdgetAttachmentFile(messageId, partName)¶
Gets the content of an attachment as a DOM File object.
messageIdpartNameThe most simple way to get the content of an attachment is to use the text() method of the File object:
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();
}
query(queryInfo)¶
Gets all messages that have the specified properties, or all messages if no properties are specified.
queryInfoauthor]body]flagged]fromMe]fullText]headerMessageId]recipients]subject]toMe]unread]update(messageId, newProperties)¶
Marks or unmarks a message as read, flagged, or tagged.
messageIdnewPropertiesflagged]junk]read]tags]move(messageIds, destination)¶
Moves messages to a specified folder.
messageIdscopy(messageIds, destination)¶
Copies messages to a specified folder.
messageIdsdelete(messageIds, [skipTrash])¶
Deletes messages, or moves them to the trash folder.
messageIdsskipTrash]archive(messageIds)¶
Archives messages using the current settings.
messageIdslistTags()¶
Returns a list of tags that can be set on messages, and their human-friendly name, colour, and sort order.
Events¶
onNewMailReceived(folder, messages)¶
Fired when a new message is received, and has been through junk classification and message filters.
Types¶
Attachment¶
Represents an attachment in a message.
contentTypenamepartNamesizeMessageHeader¶
Basic information about a message.
authorbccListccListflaggedheaderMessageIdidjunkjunkScorereadrecipientssizesubjecttagsMessageList¶
See Working with Message Lists for more information.
MessagePart¶
Represents an email message “part”, which could be the whole message
body]contentType]headers]name]partName]size]MessageTag¶
colorkeyordinaltagTagsDetail¶
Used for filtering messages by tag in various methods. Note that functions using this type may have a partial implementation.
modeWhether all of the tag filters must apply, or any of them.
Supported values:
allanytagstrue if the message must have the tag, or false if it must not have the tag. For a list of available tags, call the listTags() method.