Microsoft Exchange · Arazzo Workflow

Microsoft Exchange Compose, Attach, and Send Mail

Version 1.0.0

Create a draft message, add a file attachment to it, then send the draft.

1 workflow 1 source API 1 provider
View Spec View on GitHub CalendarCollaborationContactsEmailEnterpriseArazzoWorkflows

Provider

microsoft-exchange

Workflows

compose-attach-send-mail
Draft a message, attach a file, and send it via Microsoft Graph.
Creates a draft message with subject, body, and recipients, adds a single file attachment to the draft, and submits the draft for delivery.
3 steps inputs: attachmentContentBytes, attachmentContentType, attachmentName, bodyContent, subject, toAddress outputs: attachmentId, messageId, sentStatus
1
createDraft
createDraftMessage
Create a draft message in the Drafts folder with a subject, HTML body, and a single To recipient.
2
addAttachment
addMessageAttachment
Attach a base64-encoded file to the draft message using the fileAttachment OData type.
3
sendDraft
sendDraftMessage
Send the prepared draft message. Microsoft Graph accepts the request for delivery and saves the message in Sent Items.

Source API Descriptions

Arazzo Workflow Specification

microsoft-exchange-compose-attach-send-mail-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Microsoft Exchange Compose, Attach, and Send Mail
  summary: Create a draft message, add a file attachment to it, then send the draft.
  description: >-
    The canonical Microsoft Graph mail composition pattern. The workflow creates
    a draft message in the signed-in user's Drafts folder, attaches a
    base64-encoded file to the draft, and then sends the completed draft so it
    lands in the Sent Items folder. Each step spells out its request inline so
    the flow can be read and executed without opening the underlying OpenAPI
    description.
  version: 1.0.0
sourceDescriptions:
- name: graphMailApi
  url: ../openapi/microsoft-exchange-graph-mail-openapi.yml
  type: openapi
workflows:
- workflowId: compose-attach-send-mail
  summary: Draft a message, attach a file, and send it via Microsoft Graph.
  description: >-
    Creates a draft message with subject, body, and recipients, adds a single
    file attachment to the draft, and submits the draft for delivery.
  inputs:
    type: object
    required:
    - subject
    - bodyContent
    - toAddress
    - attachmentName
    - attachmentContentType
    - attachmentContentBytes
    properties:
      subject:
        type: string
        description: The subject line of the message.
      bodyContent:
        type: string
        description: The HTML body content of the message.
      toAddress:
        type: string
        description: The primary recipient email address.
      attachmentName:
        type: string
        description: The display name of the file attachment.
      attachmentContentType:
        type: string
        description: The MIME type of the attachment (e.g. application/pdf).
      attachmentContentBytes:
        type: string
        description: The base64-encoded contents of the attachment file.
  steps:
  - stepId: createDraft
    description: >-
      Create a draft message in the Drafts folder with a subject, HTML body,
      and a single To recipient.
    operationId: createDraftMessage
    requestBody:
      contentType: application/json
      payload:
        subject: $inputs.subject
        body:
          contentType: html
          content: $inputs.bodyContent
        toRecipients:
        - emailAddress:
            address: $inputs.toAddress
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      messageId: $response.body#/id
      isDraft: $response.body#/isDraft
  - stepId: addAttachment
    description: >-
      Attach a base64-encoded file to the draft message using the
      fileAttachment OData type.
    operationId: addMessageAttachment
    parameters:
    - name: message-id
      in: path
      value: $steps.createDraft.outputs.messageId
    requestBody:
      contentType: application/json
      payload:
        '@odata.type': '#microsoft.graph.fileAttachment'
        name: $inputs.attachmentName
        contentType: $inputs.attachmentContentType
        contentBytes: $inputs.attachmentContentBytes
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      attachmentId: $response.body#/id
  - stepId: sendDraft
    description: >-
      Send the prepared draft message. Microsoft Graph accepts the request for
      delivery and saves the message in Sent Items.
    operationId: sendDraftMessage
    parameters:
    - name: message-id
      in: path
      value: $steps.createDraft.outputs.messageId
    successCriteria:
    - condition: $statusCode == 202
    outputs:
      sentStatus: $statusCode
  outputs:
    messageId: $steps.createDraft.outputs.messageId
    attachmentId: $steps.addAttachment.outputs.attachmentId
    sentStatus: $steps.sendDraft.outputs.sentStatus