Skip to content

Outlook ​

This documents the Outlook module and how to use it from JavaScript flows.

You can load the module using the following code:

js
var outlook = Module.load("Outlook", {version: "2.0.4"});

Folders ​

The Outlook module has a folders property that contains a list of all the folders in the user’s mailbox. Each folder has the following properties:

  • name: The name of the folder
  • mails: A list of all the mails in the folder
  • folders: The folder’s own subfolders
  • getFolder(name): The named subfolder of this folder, or null if there is none

Four special folders are available as properties on the folders object and on the module itself: inbox, outbox, sent and deleted.

js
var inbox = outlook.inbox;
// also 
var sameInbox = outlook.folders.inbox;

var sentItems = outlook.sent;
var deletedItems = outlook.deleted;

Create a new folder ​

Create a new top-level folder. The folder will be created in the root of the mailbox.

WARNING

It might not be possible to create a top-level folder. This depends on the user’s mailbox configuration.

js
var newFolder = outlook.createFolder("My new folder");

You can also create a subfolder of an existing folder:

js
// newFolder is the folder created in the example above
var newSubFolder = newFolder.createFolder("My new folder");

Mails ​

Each mail has the following properties:

  • subject: The subject of the mail
  • body: The body of the mail
  • from: The sender of the mail
  • to: The recipients of the mail
  • cc: The CC recipients of the mail
  • bcc: The BCC recipients of the mail
  • attachments: A list of attachments
  • received: The received datetime of the mail
  • sent: The sent datetime of the mail
  • created: The datetime the mail was created
  • modified: The datetime the mail was last modified
  • read: Whether the mail has been read (get and set)
  • important: Whether the mail is marked as important (get and set)
  • flagged: Whether the mail is flagged (get and set)

A mail object also has the following methods:

  • reply(info): Reply to the mail with the given info object - should contain a body property at least
  • replyAll(info): Reply to all recipients of the mail with the given info object - should contain a body property at least
  • forward(info): Forward the mail with the given info object - should contain a body property at least
  • move(folder): Move the mail to the given folder (must be a folder object)
  • saveAs(path): Save the mail itself to the given path
  • delete(): Delete the mail

Sending a mail ​

To send a new mail, use the send method on the module:

js
const outlook = Module.load("Outlook", {version: "2.0.4"});
outlook.send({
    to: "john@doe.org",
    subject: "Hello",
    body: "Hello John!"
});

You can use the following properties in the mail object:

  • to: The recipient of the mail
  • cc: The CC recipient of the mail
  • bcc: The BCC recipient of the mail
  • subject: The subject of the mail
  • body: The body of the mail
  • attachments: A list of paths to files to attach

Attachments ​

Each attachment has the following properties:

  • name: The attachment’s display name
  • filename: The attachment’s file name, which can differ from the display name
  • path: The path to the attachment on disk
  • size: The size of the attachment in bytes

It also has a save(path) method that saves the attachment to the given path.