Printable
Version
 

FileMaker emailing via Applescript, XMail & a custom function

Mac only solution (PPC/Intel)

FileMaker Pro 11 does not have full email power (maybe 12 will!). I've been using this since version 5, but just rewritten to make neat and tidy for my v11 conversion job.

FileMaker & XMail integration

  • FileMaker's emailing power needs a boost: XMail

      The principle reason I use this is to gain HTML email functionality and easily automate attachment(s) inclusion (handles up to 3 with current code v1.1).

  • XMail & Applescript

      XMail is an open source Applescript osax. Even if you have never used Applescript or heard of osaxen before, you can take advantage of these two beasts as the custom function supplied gets round any of their complexity of use!

Custom Function

  • custom function

      To utilise Applescript within FileMaker is a task full of frustration and error potential. Therefore to be really useful reliable generation of Applescript using Xmail is required. It must create the Applescript code correctly every time from a varying bunch of parameters. A custom function is most suited to doing this. So we will have a simple custom function call to make:

      Perform Applescript ( XMail_CustomFunction ( _varyingParameters ) )

      The custom function (which is slightly documented internally) actually looks like this:

      XMail ( _from; _to; _subject; _body; _bodyHTML; _attachmentPaths; _dict)

      Most options used are included as their own named parameters, however, you will notice a 'dict' parameter, which is short for 'dictionary'…

  • Dictionary needs

      I wished to create an unchanging custom function with a fixed number of parameters, that nonetheless allowed the full use of XMail options as required: parameters such as cc, bcc, reply-to, priority, and the varied smtp server settings. A dictionary (a collection of name & value pairs) is required to facilitate this.

      This will be no surprise to anyone who looked at my rather more complex demo on multi-dimensional lists & dictionaries within FileMaker. I only used two dictionary functions for this:

      You won't need to install either if you already use my or SixFriedRice's fine & simpler implementation, but you will probably need to change the names within the custom function panel of the demo before copying the AppleScript_XMail custom function from demo to paste it working into your file.

      AppleScript_XMail (
         "Bryan Furbitson <tom@apple.co.uk>" ;
         "jim.bob@wagner.org, Bill Gates <bill.gates@apple.com>" ;
         "as_xmail test" ;
         "my plain text¶return test¶full on with \"quotes\"" ;
         "my html text¶<BR>return test¶<BR>
      <B><a href=\"http://www.harmlesswise.com/it\">full on</a></B> with <i>\"quotes\"</i>";
         "" ; // i.e. no attachments
         // ------- DICTIONARY BELOW
         #("cc";"me@name.co.uk") &
            #("bcc";"Random Guy <xyz@zyc.com>, technical@somerandom.co.uk") &
            #("priority";1)

      )


      demo of custom function use illustrating use of dictionary

      The arguments for having a 'dictionary' custom function implementation of some sort are overwhelming, so you really ought to read Six Frid Rice's articles (one [already linked to above] & two) and use their implementation - while shortening the names for ease of use (as they do in-house). I woudl recommend against installation of mine until you've understood and are familiar with SFR's, it is (perhaps) off-puttingly heavyweight and complex, though there are strong enough reasons for using it!

  • demo file

Donate 2 Donationware!

      Donationware is great. What if the software doesn't work well? You don't pay a penny. What if it does? You give them some money to encourage the broader principle/further development. People producing fine and useful software should be rewarded. It'll be cheaper than buying a plug-in any day of the week. Per seat licenses! Special installs and trix... Oh what a pain!

      If you appreciate this as much as I have, please consider buying an XMail license to encourage Jean-Baptiste to develop it for Snow Leopard in time (assuming FM haven't pulled their finger out by then!).



footnotes

    Links in footnotes were correct at time of writing. If you find dead ones, please let me know. In a number of cases I have saved a copy of the linked page/file, and can make this available on request.

  • 1: ^   Version 1.2:   Tiny error corrected! One missing linebreak meant if you sent an attachment sometimes whole email format would break under some clients.

  • 2: ^   Version 1.1:   RFC2822 compliance re: line breaks worked in. Using FM 'substitute' in custom function to introduce linebreaks that will almost certainly be more frequent than the recommended 998 characters (+\ \ totalling 1000).

  • 3: ^   Original, as I thought at the time unusually rigourously tested, but I was wrong. Humourously saw emails with LeStang from 3/4 years ago discussing the linebreak issues which I'd encountered then too!