Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Send Mail Script Step - Attachments & File Paths


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

Recommended Posts

Posted

I am working on a hosted/multiuser FMP7 solution whose clients will be Mac OS X only.

I would like to use the Send Mail script step for creation of e-mail messages with attachments.

For the purposes of this question, let's currently assume that the file I wish to attach will be on the user's Desktop, and I will know the exact filename of the file to be attached, and that the filename will always be the same in all cases in which the script runs.

Since the Send Mail script step requires a hardcoded file reference when using "Attach File", can anyone give me any insight into how best to specify this file reference? Remember that (1) my solution will be a hosted one, so the actual db files will be residing on a server, (2) the file to be attached will be on the local client's Desktop, (3) the solution is a multi-user one so I cannot depend on the volume name to be the same on every client.

If I use a relative file path reference, (ie: file:myFile.pdf), then what is the "root" of that relative path? The local volume's root? The server directory in which the hosted db files reside in the server? Something else?

Any insight anyone could provide to get me on the right track on this one would be great.

Of course, my followup questions will be about cases in which the filename of the file to be attached needs to be dynamic, but that is for a subsequent post...

rrr

Posted

There are several posts here relevant to this problem. Most of them were about either PDFs or images in container fields. But it's the same problem.

I think the hard drive names should be the same. It's a FileMaker problem. As you've noticed, FileMaker requires a fixed file reference. A work-around is to use the FileMaker application folder. But I don't like that. I think people who expect this kind of functionality in a networked situation should have standard "Macintosh HD" as the name of their startup drive.

If the hard drives are consistent, then you can use the "Macintosh HD:Users:Shared:" folder. Everyone has access to this, on their own computer. These things are resolved on each client machine.

Another folder is "Macintosh HD:private:tmp:501:TemporaryItems:", which is appropriate for temporary items (duh :-).

The users desktop cannot be referenced by FileMaker, because it contains the short user name. It can however be easily found by AppleScript, "path to desktop".

So, get the file from the users desktop, copy it to the temporary items folder, and attach it to the email. Here's a little test for Script Editor. Put your own "file on the desktop" instead of "metatest.xsl".

set theFile to ((path to desktop) as string) & "metatest.xsl"

tell application "Finder"

duplicate file theFile to (path to temporary items) with replacing

end tell

list folder (path to temporary items)

Posted

Let's back up a minute, then, and revisit one of my original questions:

If I use a relative file path reference, (ie: file:myFile.pdf), then what is the "root" of that relative path? The local volume's root? The server directory in which the hosted db files reside in the server? Something else?

I know that in a non-hosted solution, the root is the same directory in which the .fm7 db file resides, but how about in a hosted situation?

rrr

Posted

I believe that relative paths always resolve as the relative file path from the actual FileMaker file. This doesn't work if that is on the host machine (except for the host). It's the only machine that has the FileMaker file, so it's the only one that could resolve a relative reference from it.

Exports, and Imports resolve on the client machine. The client does not have (or should not have) OS sharing access to the FileMaker host machine. So it couldn't access a file there anyway.

If you established the export to (import from) another 3rd machine, whose volume was mounted on all machines, then that would work also. But that is not necessary, as long as some other standard path is available that will resolve on the client machine; which there is on OS X, unless someone has renamed their hard drive.

Posted

Well, that's extremely lame, in my opinion.

At the very least, "absolute" files references should be able to abstract the Volume name in the same way a rooted Unix path does:

file:/Users/Shared/myFile.txt

That way, we could shoot for directories we knew would exist on every volume but not necessarily care that the volume names might differ from user to user.

Or Filemaker could go a long way to help us by improving the Send Mail script step so that the attachment file path can be dynamically generated from a field or calculation.

As it stands, I will probably have to forget about using the Send Mail script step altogether and do everything with AppleScript. This is highly unfortunate though, because now I have to worry about coding for different e-mail clients, and somehow trapping for the users' chosen e-mail client.

Boo.

rrr

Posted

I would agree with you there. FileMaker 7 has finally let us see and edit the Import and Export File References. But they are not dynamic, and we cannot script them.

There is some possibility to use "../../", but that doesn't really help, because you'd have to know the exact depth of the FileMaker database file. Since you cannot script the Export File Reference you can't use a calculation to get the right number of "../", which would be fairly easy otherwise. Example:

file:../../Shared/Test.txt

Works to Export from a FileMaker database on the desktop to the Shared folder. But who's going to keep their database on the desktop, or at some fixed depth?

If you want to use AppleScript only, you could try this free email OSAX. I've only tried it for a simple email, but it seemed to work:

http://osaxen.com/xmail.html

Of course, it's not being updated regularly, so who knows about Tiger compatibility.

There's also 24u Email OSAX, which is $27 for 1, $7 for additional 1 (cheaper than FileMaker plug-ins).

http://www.24usoftware.com/osaxen.php

  • 7 months later...

This topic is 6924 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.