Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

E-mail via AppleScript with an attachment in FP7

Featured Replies

Hi there.

I've installed the Xmail (OSAX style) Scripting Addition.

I'm trying to have Filemaker generate a calculated Applescript that

sends attachments to a file (or files, hopefully), specificied by the path

of a container field. I can send emails fine with the script, but can't seem

to send an attachment (regardless of whether the file is local or on a mounted

network drive). The path I'm trying to send to is valid, because the

send mail script step sends the attachment just fine.

Could someone please take a peek and take a guess as to what's wrong ?

Here's what the calculated script ends up looking like:

Set toList to {

I've got XMail, but haven't used it yet; looks good though; can't beat the price. Two things off the bat. First, and this may just be the way you've posted this; an AppleScript command is generally all on 1-line. All of the above should be one line. You can "break" the line for readability by typing an Option-Return (looks like a baby return :-)

The fatal flaw however is that you're trying to use a FileMaker type file path. AppleScript uses either the old Mac style file path, or a UNIX file path (which is closer to FileMaker's), with the "POSIX path of" coercion; but neither are the same as FileMaker's path (especially with the "filemac:" part). Why can't they all be the same you may ask; alas in vain.

"filemac:/Earth/Users/johnny/Desktop/2004class4.jpg"

could be constructed as:

alias ( (path to desktop as string) & "2004class4.jpg")

path to desktop returning the current user's desktop. If you have the file name in a field (in FileMaker, this would be in a Perform AppleScript step), you could set that into an AppleScript variable, then just tack it on:

tell current record of window 1 -- or whatever

set fileName to cell "File Name"

end tell

set theFile to alias ((path to desktop as string) & fileName)

I don't know if it insists on a list, or if it's happy with just a single file. Usually they are. If not, then add "as list" to the end, with () parenthesis around the rest.

set theFile to (alias ((path to desktop as string) & fileName)) as list

Calculated applescripts are not the way to go. Paste the script into a "perfom applescript" step.

One of the problems I see in your script is all the returns.

Set toList to {

  • Author

thanks a lot guys.

this works: set theFile to (alias ((path to desktop as string) & fileName))

but.. I'm trying to pull the filenames from the container fields on each of my records.

(so, I'm thinking that I'll be declaring a variable that sets attachments to a few files, separated by

commas in the appropriate applescript syntax)

they often, will not be on the desktop of the server.. is there a way to dynamically convert the path that

filemaker container field sees into a path that applescript can use ?

(or a way I can at least figure out what the applescript path needs to be so that I can convert them by some brute force calculation)

Fenton--when you say tell current record of window 1 -- or whatever

is the #1 here actually the window name as a string or do I need to find the window ID ?

Bruce- when you say calculated applescripts are not the way to go --what is the problem with them... is this because I should rather use the method Fenton describes:

tell current record of window 1 -- or whatever

set fileName to cell "File Name"

end tell

set theFile to alias ((path to desktop as string) & fileName)

again, thanks guys.

This calculation gives me a Mac file path from an image inserted as file reference. You'd change the "imagemac:" to "filemac:" for a file (I think):

Substitute(MiddleValues(GetAsText(PictAsRef); 3; 1); [ "/"; ":"]; ["imagemac::"; ""], ["

  • Author

got it !! thanks a lot.. I didn't have much hope at first that I'd be able to get this working... it took me a little while to wrap my head around Applescript..(and I'm not a programmer) I think it's making more sense now! and at the very least, its' working!

thanks again.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.