Jump to content

E-mail via AppleScript with an attachment in FP7


This topic is 7241 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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 {

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 {

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 7241 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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