updateDraft

Update a draft message.

function updateDraft(draftId: string, update: object, cancelToken?: CancelToken): Promise<void>;

Parameters

Parameter

Type

Description

draftId

String

ID of the draft to update.

update

Object

Properties of the draft to update.

update.to

Array of String (optional)

Handles to send the message to.

update.cc

Array of String (optional)

Handles to add in copy of the message. Supported only for email channels.

update.bcc

Array of String (optional)

Handles to add in blind copy of the message. Supported only for email channels.

update.subject

String (optional)

Subject of the message.

update.content

Object (optional)

Content properties of the draft.

update.content.body

String

Content of the message.

update.content.type

String

Content type of the body. Can be either html or text.

update.attachments

Array of File (optional)

Files to attach to the message.

update.updateMode

String

cancelToken

CancelToken (optional)

Token to cancel the request.

Content type

The type of the draft.content.body property is defined in draft.content.type. It can be either text or html.
Front will convert the content in a format that matches the teammate's composer preferences.

Update mode

When updating a draft, you need to set the updateMode. It can be one of

  • insert to insert the properties while keeping the existing ones. It will append the recipients and subject as well as insert the content where the caret is.
  • replace to replace the properties of the draft.

Return value

The function returns a promise that resolves with the draft message created.

Examples

Front.updateDraft('dra_uid:xxx', {
  updateMode: 'insert',
  content: {
    body: 'Please refer to this <a href="https://example.com">useful link</a>.',
    type: 'html'
  }
});
Front.updateDraft('dra_uid:xxx', {
  updateMode: 'replace',
  to: ['[email protected]'],
  // Make sure no recipient is cc'd or bcc'd.
  cc: [],
  bcc: []
});