Magidoc

createMailDraft
Mutation

Create an email draft in the caller's connected Gmail or Outlook mailbox. Never sends: the draft stays in the mailbox's Drafts folder for the user to review and send themselves.

The HTML body is stored exactly as given (links are not rewritten or wrapped). Gmail drafts also carry a text/plain alternative derived from the HTML; Outlook derives its own on send.

For a reply draft pass inReplyTo (the replied-to message's internetMessageId) and, for Gmail, its threadId. Returns the created draft; its draftId is the id for updateMailDraft, updateMailDraftBody, getMailDraft and deleteMailDraft.

Access: Requires authenticated user with connected mail provider.

Errors:

  • User is not logged in
  • User does not have specified providerId connected
  • Unsupported mail provider
  • Recipient contains a line break
  • Outlook reply target not found in the mailbox

Arguments

#

providerId

Connected mailbox account id; omit for the user's primary mailbox.

subject

Non-null

body

Non-null

Complete HTML body, stored verbatim.

to

Non-null

Recipients; may be empty.

threadId

Gmail thread id of the conversation this draft replies to. Ignored by Outlook.

inReplyTo

internetMessageId of the message this draft replies to.

attachFileIds

[ID !]

Hive file ids to attach. To attach a local file, upload it with prepareFileLibraryUploads, PUT the bytes, then completeFileLibraryUploads, and pass the returned file ids here; the caller must be able to read each file. At most 20 files and 25 MB in total; Outlook takes files up to 3 MB each.

Response

#

Returns MailMessage .

Example

#