Class: Message

Message

new Message(jmap, id, blobId, threadId, mailboxIds, optsopt)

This class represents a JMAP Message.
When creating a new Message instance, the following requirements must be met:

  • The threadId must be defined (in JMAP, a Message is always in a Thread)
  • The mailboxIds must contain at least one element.
Parameters:
Name Type Attributes Description
jmap Client

The Client instance that created this Message.

id String

The unique identifier of this Message.

blobId String

The identifier representing the raw [@!RFC5322] message.

threadId String

The unique identifier of the Thread this Message is in.

mailboxIds Array.<String>

The array of Mailbox identifiers this Message is present into.

opts Object <optional>

The optional properties of this Message.

Properties
Name Type Attributes Default Description
inReplyToMessageId String <optional>
null

The id of the Message this Message is a reply to.

isUnread Boolean <optional>
false

Has the message not yet been read? This maps to the opposite of the \Seen flag in IMAP.

isFlagged Boolean <optional>
false

Is the message flagged? This maps to the \Flagged flag in IMAP.

isAnswered Boolean <optional>
false

Has the message been replied to? This maps to the \Answered flag in IMAP.

isDraft Boolean <optional>
false

Is the message a draft? This maps to the \Draft flag in IMAP.

hasAttachment Boolean <optional>
false

Does the message have any attachments?

headers Object <optional>

A hash of header name to header value for all headers in the message. For headers that occur multiple times, the values are concatenated with a single new line (\n) character in between each one.

from EMailer <optional>
null

The EMailer object representing the first identified sender of this Message.

to Array.<EMailer> <optional>
[EMailer.unknown]

The array of EMailer objects representing the To: of this Message.

cc Array.<EMailer> <optional>
[EMailer.unknown]

The array of EMailer objects representing the CC: of this Message.

bcc Array.<EMailer> <optional>
[EMailer.unknown]

The array of EMailer objects representing the BCC: of this Message.

replyTo Array.<EMailer> <optional>
EMailer.unknown

The array of EMailer objects representing the Reply-To: of this Message.

subject String <optional>
null

The subject of this Message.

date Date <optional>
null

The date the Message was sent (or saved, if the message is a draft).

size String <optional>
0

The size in bytes of the whole message as counted by the server.

preview String <optional>
null

Up to 256 characters of the beginning of a plain text version of the Message body.

textBody String <optional>
null

The plain text body part for the Message.

htmlBody String <optional>
null

The HTML body part for the Message, if present.

attachments Array.<Attachment> <optional>
[]

An array of Attachment objects detailing all the attachments to the message.

Source:
See:

Extends

Methods

(static) fromJSONObject(jmap, object) → {Message}

Creates a Message from its JSON representation.

Parameters:
Name Type Description
jmap Client

The Client instance passed to the Message constructor.

object Object

The JSON representation of the Message, as a Javascript object.

Properties
Name Type Description
id Object

The identifier of the Message.

blobId String

The identifier representing the raw [@!RFC5322] message.

threadId String

The identifier of the thread the Message is in.

mailboxIds Array.<String>

The array of Mailbox identifiers the Message is present into.

Source:
Returns:
Type
Message

destroy() → {Promise}

Destroy this Message on the server.

Source:
See:
Returns:

A Promise, as per Client.destroyMessage.

Type
Promise

move(mailboxIds) → {Promise}

Moves this Message to a different set of mailboxes.

Parameters:
Name Type Description
mailboxIds Array.<String>

The identifiers of the target mailboxes for the message.

Source:
See:
Returns:

A Promise, as per Client.moveMessage.

Type
Promise

moveToMailboxWithRole(role) → {Promise}

Moves this Message to the mailbox holding the given role.
This will first do a JMAP request to find the mailbox with the given role, then a Message#move to move the message.

Parameters:
Name Type Description
role MailboxRole | String

The desired mailbox role.

Source:
See:
Returns:

A Promise, as per Message#move.

Type
Promise

setIsAnswered(isAnswered) → {Promise}

Updates the isAnswered field of this Message.

Parameters:
Name Type Description
isAnswered Boolean

The isAnswered field of the message.

Source:
See:
Returns:

A Promise, as per Client.updateMessage.

Type
Promise

setIsFlagged(isFlagged) → {Promise}

Updates the isFlagged field of this Message.

Parameters:
Name Type Description
isFlagged Boolean

The isFlagged field of the message.

Source:
See:
Returns:

A Promise, as per Client.updateMessage.

Type
Promise

setIsUnread(isUnread) → {Promise}

Updates the isUnread field of this Message.

Parameters:
Name Type Description
isUnread Boolean

The isUnread field of the message.

Source:
See:
Returns:

A Promise, as per Client.updateMessage.

Type
Promise

update(options) → {Promise}

Updates this Message.

Parameters:
Name Type Description
options Object

The options to be updated in this Message as per Client.updateMessage.

Source:
See:
Returns:

A Promise, as per Client.updateMessage.

Type
Promise