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 OmniGraffle 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 = "Omni Automation" | |
03 | email.body = "Greetings!\n\nHere are my suggestions regarding Omni Automation:" | |
03 | email.receiver = "support@omnigroup.com" | |
04 | email.generate() |
Including Attachments
The following are examples of creating and sending mail messages whose contents are derived from the current document.
NOTE: The image attachment in the following example is created using the current document export settings.
Mail Image of Current Canvas | ||
01 | var docName = document.name | |
02 | var fileTypeID = 'public.png' | |
03 | var wrapperPromise = document.makeFileWrapper(docName, fileTypeID) | |
04 | ||
05 | wrapperPromise.then(function(wrapper){ | |
06 | var email = new Email() | |
07 | email.subject = "PNG of “" + docName + "”" | |
08 | email.body = "Here is the exported canvas for you!\n\n" | |
09 | email.fileWrappers = [wrapper] | |
10 | email.generate() | |
11 | }) | |
12 | ||
13 | wrapperPromise.catch(function(err){ | |
14 | console.error(err.message) | |
15 | }) |
Mail Canvas Image and Document | ||
01 | var docName = document.name | |
02 | var OGDwrapperPromise = document.makeFileWrapper(docName, "com.omnigroup.omnigraffle.graffle") | |
03 | var PNGwrapperPromise = document.makeFileWrapper(docName, "public.png") | |
04 | var promises = [PNGwrapperPromise, OGDwrapperPromise] | |
05 | ||
06 | Promise.all(promises).then(function(wrappers){ | |
07 | var email = new Email() | |
08 | email.subject = "Exports of “" + docName + "”" | |
09 | email.body = "Here are the exported canvas and file:\n\n" | |
10 | email.fileWrappers = wrappers | |
11 | email.generate() | |
12 | }).catch(function(err){ | |
13 | console.log("Error", err.message) | |
14 | }) |
This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.