FileMaker 17 – attach more

With the release of FileMaker Pro 17, a long-time feature request has been delivered – the ability to attach multiple files to an email.

Send Email

The Send Mail script step is used to compose and send an email from a FileMaker solution.

Send Mail 17

The change in FileMaker 17 is the Attach Files button in the lower left. Clicking this button allows multiple file paths to be set:

Send Mail path 17

Developers will usually specify a variable to define the file path. In past versions, this would have been a single path ending in a file name. In FileMaker 17, the variable can be a list of file paths, one for each attachment.

Attaching Multiple files to Email

So a script to send invoices for a current customer record looks like:

Go to Related Record [“Invoices”; only related]
If [ Get ( LastError ) = 0 ]
  Go to Record/Request/Page[First]
    Go to Related Record [ “Invoice Data”; 
                          only related; new window]
    Set Variable [$FILE; Value: calc below]
    Save Records as PDF [ File Name: “$FILE”]
    Set Variable [$LIST; Value:List($LIST; $FILE)]
    Close Window [Current Window]
    Go to Record/Request/Page[Next;Exit after last]
  End Loop
Send Mail [ E-mail Client; Attachments: “$LIST”]
End If

The $FILE variable is set with a calculation like:

Let ([ path = Get ( TemporaryPath ) ; 
       file = "Inv_" & Invoices::Invoice ID & ".pdf"
       path & file

This value is used as the file name for Save Records as PDF. Each PDF will have a unique name and will be saved in the temporary path.

The $LIST variable is used to assemble all the file paths for the attachments. It is ultimately used in the Send Mail step. It appends each new file to a list for each loop using:

List ( $LIST; $FILE )

Backwards Compatibility

As with all new features, it is important to account for users who may not be running version 17 clients. Either the file needs to lock those users out, or the script needs to detect the client version and have  modified action.

Leave a Reply

Your email address will not be published. Required fields are marked *