Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can.
-Jamie Zawinski's Law of Software Envelopment
The 360Works Email Plugin offers the following advantages over FileMaker's built-in mail functionality:
Set Variable [ $result = EmailRegister( "mylicensekey", "My Company" ) and EmailConnect( "mail.example.com" ) and EmailQuickSend( Email::from ; // required "from" address Email::to ; // comma-separated list of addresses Email::subject ; // subject of the message Email::body ; // message body Email::attach // path or URL or container to attach ) ]
Sending a plain-text email with one attachment:
Set Variable [ $result =
EmailRegister("myLicenseKey"; "My Company") and
EmailConnect( "mail.example.com" ) and
EmailCreate( Email::from ; Email::to ; Email::subject ) and
EmailSetBody( Email::body ; "plain" ) and
EmailAttachFile( $attachment ) and
EmailSend
]
Sending an HTML-formatted email (converts formatted FileMaker text to HTML using the GetAsCSS function):
Set Variable [ $result =
EmailRegister("myLicenseKey"; "My Company") and
EmailConnect( "mail.example.com" ) and
EmailCreate( Email::from ; Email::to ; Email::subject ) and
EmailSetBody( GetAsCSS( Email::body ); "html" ) and
EmailSend
]
Sending a single message multiple times to different recipients can be done by creating a message using EmailCreate, then calling EmailRecipients and EmailSend multiple times. If you are sending large messages with attachments, this avoids the overhead of creating a separate message for each recipient.
file:///path/to/attachment.jpg).
Here is a brief example of how to read the first 25 unread messages from the server:
set variable $registerResult = EmailRegister ( license ; company ) // check for registration success here set variable $connectResult = EmailConnectIMAP( server ; username ; password ) // check for connection success here set variable $$importUrl = EmailReadMessages ( "mailbox=INBOX" ; "viewed=false" ; "max=25" ; "attachments=true" ) // check for import success here If [$$importUrl = "ERROR"] Show Custom Dialog [EmailLastError] Exit Script End If // Import the email messages from the local XML file // which was created by the EmailReadMessages function Import records [$$importUrl ; Update Matching]
If you're running on FileMaker server or via IWP/CWP, you'll need to iterate over the messages, since [Import XML] is not a web-safe script step. The general pattern looks like this:
set variable $$importUrl = EmailReadMessages ( "mailbox=INBOX" ; "viewed=false" ; "max=25" ; "attachments=true" // check for import success here Loop Exit Loop If [not EmailGetNextMessage] New Record/Request Set Field[ImportedMessage::from ; EmailReadMessageValue( "from" )] Set Field[ImportedMessage::to ; EmailReadMessageValue( "to" )] Set Field[ImportedMessage::subject ; EmailReadMessageValue( "subject" )] Set Field[ImportedMessage::body ; EmailReadMessageValue( "body" )] Set Field[ImportedMessage::messageId ; EmailReadMessageValue( "messageId" )] End Loop
readonly=false.
Note: setting readonly=false will cause any fetched messages to be marked as "viewed"! Then iterate to a message using the EmailGetNextMessage function.
Finally, use the EmailMessageSetFlag function to apply flags to a message (such as deleted, flagged, viewed, etc).
Here is an example of how to fetch any unread messages from a mailbox, marking them all as viewed (by setting readonly=false).
Additionally, any messages from a certain address are marked as deleted:
Set Variable [ $result = EmailReadMessages( "viewed=false" ; "readonly=false" ) ]
If [$result = "ERROR"]
# Handle Error Here...
End If
Loop
Exit Loop If [not EmailGetNextMessage]
Set Variable[$result ; EmailMessageSetFlag("read")
If [EmailReadMessageValue("from") = "deleteme@example.com"]
Set Variable[$result ; EmailMessageSetFlag("deleted")
End If
End Loop
FileMaker version 7 or higher.
Java Virtual Machine (JVM) version 1.4.2 or later. If you are running a JVM earlier than 1.4.2, you should upgrade. Download a JVM from http://www.java.com/en/download/. If you are not sure what version of Java you have installed, you can do 'java -version' on the command line in Windows or OS X.
Windows, or Mac OS X version 10.4 or higher.
Note to intel Mac users: running this plugin under Rosetta is not supported. Upgrade to FileMaker 8.5 to run our plugin in native Intel mode.
Drag the plugin from the MAC or WIN folder into your FileMaker extensions, and restart FileMaker. You will need to enter your license key before you can use it. After FileMaker starts up with the plugin installed, open FileMaker preferences, click on the Plug-ins tab, select the plugin from the list, and click the Configure button. Enter your license key and company name in this dialog. You will only need to do this once on a given machine. Alternately, you can use the registration function to register the plugin during a startup script.
This will also enable the plugin for use with Instant Web Publishing from the FileMaker Pro client software.
If the plugin does not load correctly, double-check that you meet the system requirements.
You do not need to do this step unless you plan on using the plugin with Instant Web Publishing or Custom Web Publishing with FileMaker Server Advanced. You will need an Enterprise License to use this feature.
For installing into the Web Publishing Engine with FileMaker 9 Server or FileMaker Server Advanced, drag the plugin from the MAC or WIN folder into the FileMaker Server/Web Publishing/publishing-engine/wpc/Plugins folder. If there is no 'Plugins' folder inside the 'wpc' folder, then create it manually. Restart FileMaker Web Publishing, and now the plugins should be ready to go.
Note that you must use the registration function to register the plugin, since there is no preferences dialog in the FileMaker Web Publishing Engine to enter the license key and company name.
Note that due to a bug which we and other plugin vendors have reported to FileMaker, web plugins do not work in FileMaker Web Publishing Engine 8.0v4 on Mac OS X. You will need to use a later version, like 9, or an earlier version, like 8.0v3. The Windows FileMaker Server 8.0v4 does not have this bug, and will work correctly.
The easiest way to test whether the plugin is working is to have a calculation which calls the version function of the plugin, and display that on an IWP layout. If it shows "?", then the plugin is not working. If it shows a number, then the plugin has been installed successfully.
You do not need to do this step unless you plan on using the plugin with scheduled script triggering, a new feature in FileMaker Server 9. You will need an Enterprise License to use this feature.
FileMaker Server/Database Server/Extensions folder (older versions of server use the path FileMaker Server/Extensions/Plugins).Configuration -> Database Server->Server Plug-ins.
Note that you must use the registration function to register the plugin, since there is no preferences dialog in FileMaker Server to enter the license key and company name.
We love to hear your suggestions for improving our products! If you are experiencing problems with this plugin, or have a feature request, or are happy with it, we'd appreciate hearing about it. Send us a message on our website, or email us!
EmailReadMessages function.EmailGetNextMessage function.
EmailAttachFile("http://localhost:8080/SuperContainer/123/RawData");
-or-
EmailAttachFile("file:///path/to/invoice.pdf");
-or-
EmailAttachFile("/Macintosh HD/path/to/invoice.pdf");
-or-
EmailAttachFile(myTable::myContainerField);You can call this multiple times to attach multiple files to a message.
Note on paths vs urls: This function can also accept a path (/path/to/file) instead of a file URL (file://path/to/file). This is handy for attaching PDFs generated by FileMaker.
If called on a machine runing Mac OS X, a file URL is created from a path by prepending the directory /Volumes to the supplied path, since FileMaker includes the hard drive name in paths.
For example, /MacintoshHD/Users/John Smith/Documents/ is converted to the file URL file:///Volumes/MacintoshHD/Users/John Smith/Documents/.
data - a path to a file, or a URL pointing to a file to attach to the message.append to true if doing this).
bcc_addresses - comma-separated list of addressesappend - whether to append the new addresses to existing ones, or overwrite them.append to true if doing this).
cc_addresses - comma-separated list of addressesappend - whether to append the new addresses to existing ones, or overwrite them.EmailConnectPOP) must be called before reading email messages from the server.
This establishes a connection to the email server. When you are finished getting/sending email, it is a good idea to call EmailDisconnect to close the connection.
host - the IMAP host address. This parameter may contain a port number using a colon syntax, e.g. imap.example.com:2525username - The authentication usernamepassword - The authentication passwordEmailConnectIMAP) must be called before reading email messages from the server.
This establishes a connection to the email server. When you are finished getting/sending email, it is a good idea to call EmailDisconnect to close the connection.
host - the POP host address. This parameter may contain a port number using a colon syntax, e.g. pop.example.com:2525username - The authentication usernamepassword - The authentication passwordhost - the SMTP host address. This parameter may contain a port number using a colon syntax, e.g. smtp.example.com:2525username - The optional SMTP authentication usernamepassword - The optional SMTP authentication passwordfrom - the FROM address for the new messageto - the TO address for the new messagesubject - the SUBJECT of the new messageEmailReadMessages function.
To use this function, first call EmailReadMessages with the appropriate parameters.
Next, call EmailGetNextMessage, which returns 1 or 0 depending on whether a message was loaded.
Finally, call EmailReadMessageValue to get individual properties of the currently loaded message.
"" if there was no error.
parent - optional mailbox to traverse. If not specified/empty, the root mailbox is used.recursive - optional parameter for whether to traverse sub-folders recursively. Default is false./) character.
readonly=false to use this function.
The allowed flags are:
flag - one of the named flags to setvalue - the optional value to set the flag to. Default is 1 (or true).See EmailAttachFile for more information about how to attach a file.
from - The "from" email addressto - A comma-separated list of "to" email addressessubject - The subject of the messagebody - The message body.attachment - A container holding an attachment to include with the email, or a URL or path to a file to attach.attachments=true as a parameter to the EmailReadMessages function.
After importing an email message into FileMaker, pass any attachment paths to this function to get container data for the attachment path. For example, you might pass the following argument:
EmailReadAttachment( "/Macintosh HD/private/tmp/4545776.01203682301836.JavaMail.root@pluto.local/text.html" )The supplied path should not begin with
file:, image:, or any other prefix - just the path.
Note that this will actually work for any file, it doesn't need to be an email attachment.
path - The path as returned in the email importpath, or "ERROR" if an error occurred (use EmailLastError in this case)
If an error occurs, this function will return "ERROR". Use the EmailLastError function to get more information about the error.
After successfully calling EmailReadMessages, you can iterate over the fetched messages using the EmailGetNextMessage function. This pattern typically looks like this:
Loop Exit Loop If [not EmailGetNextMessage] New Record/Request Set Field[ImportedMessage::from ; EmailReadMessageValue( "from" )] Set Field[ImportedMessage::to ; EmailReadMessageValue( "to" )] Set Field[ImportedMessage::subject ; EmailReadMessageValue( "subject" )] Set Field[ImportedMessage::body ; EmailReadMessageValue( "body" )] Set Field[ImportedMessage::messageId ; EmailReadMessageValue( "messageId" )] End Loop
To import email data into FileMaker via XML, use the "Import Records" script step, and specify an XML data source, passing the file URL returned from this function.
Use the "messageId" field in the resulting XML as a match field when defining import options.
Note: XML import is not a web-safe script. Use the method described in "Reading Individual Messages" if your script is running in IWP or on the server, or if you need to modify individual messages on the server.
key=value arguments. You can specify any number of flags you wish.
The following is a description of the available flags:
INBOX.false, which disables attachment downloading. This is significantly faster.
If attachment downloading is disabled, you can still retrieve a list of the attachments in a message using the EmailReadMessageValue ( "attachments" ) function. You can the re-read the message at a later time to download the attachments (see the EmailClient.fp7 example file).
from addressto addresssubjectmessageIdbodytrue to return only previously viewed messages, false to return only unread messages.true to return only flagged messages, false to return only non-flagged messages.true to return only deleted messages, false to return only non-deleted messages.true (read-only).
If you plan on deleting, moving, or flagging any messages, use false in this parameter.
Note: setting readonly=false will cause any fetched messages to be marked as "viewed"!
For example, you might use the following to fetch the first 25 unread messages from your inbox:
EmailReadMessages( "imap" ; "mailbox=INBOX" ; "attachments=false" ; "max=25" ; "attachments=false" ; "viewed=false" )
flags - optional flags which control how messages are read.EmailGetNextMessage function.
If there are multiple values for a key, each value will be on a separate line.
The parameter must be one of the following values (case-insensitive):
attachments parameter in EmailReadMessages)key - The key to retrieve, must be one of the above listed keys.append to true if doing this).
to_addresses - comma-separated list of addressesappend - whether to append the new addresses to existing ones, or overwrite them.licenseKey - a valid license key string.registeredTo - the company name for the license key used.EmailSetBody( GetAsCSS( Email::body ); "html" )
body - text to be displayed in the messagecontentType - type of formatting used in the body, e.g. "plain", "html", "rtf".characterSet - optional character setheader - the header namevalue - the header valuesubject - the email message subjectemail - one or more email addresses to validate (comma-separated).email is empty.