Outlook
This documents the Outlook module and how to use it from JavaScript flows.
You can load the module using the following code:
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 foldermails: A list of all the mails in the folder
The special folder Inbox is also available as a property on the folders object and on the module itself.
var inbox = outlook.inbox;
// also
var sameInbox = outlook.folders.inbox;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.
var newFolder = outlook.createFolder("My new folder");You can also create a subfolder of an existing folder:
// 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 mailbody: The body of the mailfrom: The sender of the mailto: The recipients of the mailcc: The CC recipients of the mailbcc: The BCC recipients of the mailattachments: A list of attachmentsreceived: The received datetime of the mailsent: The sent datetime of the mailread: 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 abodyproperty at leastreplyAll(info): Reply to all recipients of the mail with the given info object - should contain abodyproperty at leastforward(info): Forward the mail with the given info object - should contain abodyproperty at leastmove(folder): Move the mail to the given folder (must be a folder object)delete(): Delete the mail
Sending a mail
To send a new mail, use the send method on the module:
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 mailcc: The CC recipient of the mailbcc: The BCC recipient of the mailsubject: The subject of the mailbody: The body of the mailattachments: A list of paths to files to attach
Attachments
Each attachment has the following properties:
name: The name of the attachmentpath: The path to the attachment on disksize: The size of the attachment in bytes
It also has a save(path) method that saves the attachment to the given path.
