Integrated eMail Support
Using Omni Automation you can construct and manipulate outline documents, apply styles and import data from a variety of sources. And with integrated scripting support for creating and sending email, it becomes easy to automate the sending of outline content and documents. The following documentation demonstrate how to access and use this ability, beginning with a set of parameters for generating an email.
Constructor
Omni Automation in OmniOutliner supports an Email class, design for creating and sending electronic mail messages. To instantiate an instance of this class, it is preceded by the new constructor.
new Email() → (Email) • Creates a new Email object.
Instance Properties
As with most scriptable objects, an instance of the Email class has properties that define its design and usage. Here is the list of properties for this class:
blindCarbonCopy (String or nil) • Blind carbon copy allows the sender of a message to conceal the person entered in the Bcc: field from the other recipients. This concept originally applied to paper correspondence and now also applies to email. (Wikipedia)
body (String or nil) • The main text content of the mail message.
carbonCopy (String or nil) • In the past, a carbon copy was the under-copy of a document created when carbon paper was placed between the original and the under-copy during the production of a document. Nowadays "carbon copy" is often used metaphorically to refer simply to an exact copy or the inclusion of a recipient of an electronic message.
fileWrappers (Array of FileWrapper) • A FileWrapper is a representation of a node (a file, directory, or symbolic link) in the file system. File wrappers represent a file system node as an object that can be displayed as an image (and possibly edited in place), saved to the file system, or transmitted to another application. In Omni Automation they are used during export to identify the format in which the outline document is to saved to file and added to the outgoing message as an attachment.
receiver (String or nil) • The person or identity to receive the mail message, represented by a standard email address string.
subject (String or nil) • The title of the mail message.
Instance Functions
The Email class contains a single command generate() for processing instances of the class.
generate() • Presents the generated email to the user for them to send (or discard). NOTE: on iOS, any included attachment FileWrappers that are directories will be converted to Zip files.
Basic eMail Script | ||
01 | var email = new Email() | |
02 | email.subject = "Contents of “" + document.name + "”" | |
03 | email.body = "Whatever content you wish to include" | |
04 | email.generate() |
The following are examples of creating and sending mail messages whose contents are derived from the current outline document.
Send Basic Text of Outline
As an example of an Omni Automation action that creates an outgoing mail message containing the contents of the current OmniOutliner document as plain tabbed text:
NOTE: On iOS and iPadOS leading spaces and tabs may be stripped from the message body.
[see Export Outline page for details regarding FileWrappers]
Send Outline as Tabbed Text | ||
01 | /*{ | |
02 | "type": "action", | |
03 | "targets": ["omnioutliner"], | |
04 | "author": "Otto Automator", | |
05 | "identifier": "com.omni-automation.oo.send-outline-as-text", | |
06 | "version": "1.0", | |
07 | "description": "This action will create a new outgoing email message whose contents is the outline as plain text with tab indents.", | |
08 | "label": "Send Outline as Text", | |
09 | "shortLabel": "Send as Text" | |
10 | }*/ | |
11 | (() => { | |
12 | var action = new PlugIn.Action(function(selection, sender){ | |
13 | // action code | |
14 | // selection options: columns, document, editor, items, nodes, outline, styles | |
15 | ||
16 | var baseName = document.name | |
17 | var fileTypeID = "public.plain-text" | |
18 | wrapperPromise = document.makeFileWrapper(baseName, fileTypeID) | |
19 | ||
20 | wrapperPromise.then(function(wrapper){ | |
21 | var email = new Email() | |
22 | email.subject = "Contents of “" + document.name + "”" | |
23 | email.body = wrapper.contents.toString() | |
24 | email.generate() | |
25 | }) | |
26 | ||
27 | wrapperPromise.catch(function(err){ | |
28 | console.error(err.message) | |
29 | }) | |
30 | }); | |
31 | ||
32 | action.validate = function(selection, sender){ | |
33 | // validation code | |
34 | // selection options: columns, document, editor, items, nodes, outline, styles | |
35 | return true | |
36 | }; | |
37 | ||
38 | return action; | |
39 | })(); |
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.