kcep Posted July 29, 2009 Posted July 29, 2009 I'm trying to send a series of emails. Each email has a different .mp3 file attached to the email ... each .mp3 is referenced to a container field (Insert QuickTime) ... one container field per record. Is there a way to do an email file attachment using a calculation? It seems like the "Send Mail" script step only allows one specific file to be attached to all the emails.
bcooney Posted July 29, 2009 Posted July 29, 2009 You need to loop thru the found set of records. Find Records Go to First Loop Send Email (attach container field) Next Rec (exit after last) End Loop
kcep Posted July 29, 2009 Author Posted July 29, 2009 (edited) Hi :-) Looping the records is not my problem. Attaching a different file to each email is the problem. In the "Send Mail" script step I can't see a way to attach the contents of a separate container field to each email. I'm on FileMaker Pro 8.0v3 ... is that my problem? Does a later version of FileMaker Pro allow this? Thanks Edited July 29, 2009 by Guest
IdealData Posted July 29, 2009 Posted July 29, 2009 You need to EXPORT FIELD CONTENTS for the container you want to attach to the e-mail. Use a $variable to generate the file name/path and use the $variable as the specified file for the attachment in the send mail script step. A small problem you will be left with the disposal of all the exported fields from the local computer. Later version of FM left you use the "TemporaryPath" to export files to and these are deleted when FM quits.
Fenton Posted July 29, 2009 Posted July 29, 2009 If you are using earlier (archaic :-) versions of FileMaker, a temporary path can be calculated from either the Get (DocumentsPath) or Get (PreferencesPath); you need this as this temp path is in the user's folder and contains the user name. The script in this example file, which just saves the current layout as a PDF, first runs a short AppleScript on a Mac, which will create the temp folder if it does not exist, simply by looking for it (kind of a unique folder). path to temporary items from user domain It also calculates the path on Windows, so should work cross-platform (been a while since I tested that). But, as IdealData says, FileMaker 10 solves the problem using the Get (TemporaryPath). This function is also in FileMaker 9, but there are questions whether the items in that case are really "temporary" (ie., they tend to just stay there). TempPath_not_FM.fp7.zip
jamesducker Posted July 29, 2009 Posted July 29, 2009 If you are worried about the temp file staying there, just do this after the send mail step: show all records show omitted export records to $fileName Exporting an empty found set is a quick and dirty way to delete $filename from your file system. Hope that helps. James
bcooney Posted July 29, 2009 Posted July 29, 2009 I'm sorry. I just dashed this off from memory, and I typically use email plugins. Glad others were here to help.
Lee Smith Posted July 29, 2009 Posted July 29, 2009 A Local veriable is cleard when the script is exited. From the FileMaker Help Prefix the name with $ for a local variable or $$ for a global variable A local variable can only be used in script steps in the currently executing script. The value in a local variable is cleared when the script exits. A global variable can be used in a calculation or script anywhere in a file, for example, other scripts or file paths. The value of a global variable is not cleared until the file is closed. HTH Lee
IdealData Posted July 30, 2009 Posted July 30, 2009 Well spotted Fenton - FM9 DOES NOT remove files which have been exported to the temporary path. There are some files that FM9 places there itself and those ARE removed. FM10 does remove items in the temporary path - it actually removes the directory! These are all observation from a Mac perspective, so no comment for Windows.
Fenton Posted July 30, 2009 Posted July 30, 2009 (edited) Actually, I believe we (IdealData and I) may have gotten off on the wrong (though interesting) track, as far as what the original poster was asking (I could be wrong; it's early). We both kind of missed that he said "each .mp3 is referenced to a container field (Insert QuickTime) ... one container field per record." So, the mp3 's are not embedded in FileMaker container fields, but are files somewhere, with their paths in a container field. So there is no need to export them (though it would work, but take extra time). In any case, his question is more about "how to use a different file path for each." bcooney and Lee were closer to the answer. But I don't think kcep knows how to use the $variables in the Send Mail step. Basically FileMaker will accept a Script Variable (it's a script step, read about it in the Help) for a file path in several dialogs (Import, Export, Send Mail). You need to set a FileMaker syntax path into the variable first, then use it. The Variable name is up to you. A FileMaker syntax path can be seen in the Help, and also at the bottom of all of those dialogs. In this case you'd use an full path, which might look like: filemac:/Macintosh HD/Users/fej/Desktop/some file.mp3 If you set (reset) your path into the $variable before each Send Mail step, and used the $variable as the path in the Attachment dialog it would work. The $variable is used as is, no quotes, just type it into the dialog as the file path. But, where to get it from. When you have a file inserted as reference, it is the last line of GetAsText (container field). So you just need a calculation to parse out the last line. Let ( [ Info = GetAsText (Contain); vc = ValueCount (Info) ]; GetValue ( Info; vc ) ) So, in a Loop, set your $variable to the above, then type $variable into the Attachment file path dialog. Edited October 15, 2010 by Guest Removed $ prefix; mistake
kcep Posted July 30, 2009 Author Posted July 30, 2009 I'm working on it :-) Thanks everyone for the suggestions. Hopefully, I will get a solution soon ;-)
Tjebbe van Tijen Posted October 11, 2009 Posted October 11, 2009 I came to this question because of a similar question and the answers were almost right for me, so I like to add this tiny thing to it: Fenton wrote: A FileMaker syntax path can be seen in the Help, and also at the bottom of all of those dialogs. In this case you'd use an full path, which might look like: $filemac:/Macintosh HD/Users/fej/Desktop/some file.mp3 This was almost clear to me, but I had to do some try & error before I figured out what Fenton actually meant. It is about the $ that indicates a local variable and which should not be made part of the file path string. $filemac:/Macintosh HD/Users/fej/Desktop/some file.mp3 May suggest that the $ sign is a part of the file path string, but it is NOT. This can be obvious for people working daily in FMP programming, but I am a user who comes back to this program only from time to time and always had had [problems with refined understanding of syntax... I need just a simple clear example. So let me give one such an example here, so other "dumbos" like me may profit: I use the script step: Set Variable and give the following calculation $EmailAttachmentPath = Substitute(AMSnote::gAttachmentFolderFilePathX; "/Volumes"; "filemac:") In my global field gAttachmentFolderFilePathX I have stored a calculated file path and name that includes a folder on a certain hard disk volume (I use InsideScan plugin for storing this and that plugin gives by default the file path in the format /Volumes/... etcetera) As I am not yet sure whether or not FMP 10 want the file path formulated as filemac: or with the /Volumes format I just reformatted the folder path name to be the same as in the example by Fenton. Almost there ... So then in the email script step I simply enter as the attachment the string $EmailAttachmentPath ... and that works perfect. I have chosen thjs way of working as I am first exporting the image I am attaching to an email to a directory that is stored in global field and want the names of the attached image files to correspond with the unique indicators of the fields in my database (I use sets of repeating fields to store my data). Last I keep wondering why in newer versions of Filemaker the option of a variable file attachment is not included. Now we have something that is in fact such a function, but seems to be more of a workaround (so freuqnetly needed in Filemaker... which I use for over a decade now).
Newbies Slisciani Posted October 14, 2010 Newbies Posted October 14, 2010 Can you dumb down further and walk through in more detail?
bcooney Posted October 14, 2010 Posted October 14, 2010 Welcome to the forums, Slisciani. You've added onto a thread that's over a year old. You may not get a response. Please start a new thread.
Fenton Posted October 15, 2010 Posted October 15, 2010 (edited) Yes. I'm afraid there was some confusion in this thread, caused by the fact that I'd typed a $ in the front of a FileMaker syntx path, which Tjebbe van Tijen noticed (I just fixed it). I did not mean to do so. I had just used that in a previous sentence, in $variables, and I guess my fingers were stuck -] We were just talking about putting a FileMaker syntax path to a file into a script variable, to use to attach an external file to an email. Yes, it is a fair amount of info in a small amount of words. It is easier to illustrate with an example file. If that is what you want to see, please tell us. Someone has an example file, or can make one. All the ones I have involve AppleScript (to do multiple attachments, etc.). But a simple Email with attachment is fairly simple to do. Just kind of tedious to explain. Edited October 15, 2010 by Guest
bcooney Posted October 15, 2010 Posted October 15, 2010 Oh, then this demo will help: http://fmforums.com/forum/showpost.php?post/320960/
Newbies Slisciani Posted October 18, 2010 Newbies Posted October 18, 2010 (edited) I would like to insert one file as a reference in each record in my data base, then be able to press a button on each record page and have an email with that file as an attachment sent. The reference file will be different for each record, but all records will email to the same email address. The name of the database is Current and the file is stored in the Forms field. I created another field called Forms Value that is a calculation field that displays the value of the file path of the forms field as text Global, = GetValue ( Forms ;2) The I created a script that first defines a variable Set Variable [$formsPath; Value:GetField ( Current::Forms Value )] Then send the mail message. The mail function is working, and I added the variable to the attachments field, yet when the message is created nothing is attached. Send Mail [To: "[email protected]"; Subject: "Test"; "$formsPath"] Any reason it would not be attached? Thanks Edited October 18, 2010 by Guest
bcooney Posted October 18, 2010 Posted October 18, 2010 $formsPath should be set to GetValue(Forms;2). You do not need the global field.
Fenton Posted October 18, 2010 Posted October 18, 2010 Don't use GetField. Just put: Current::FormsValue In other words, just point at the field itself (or just parse the path in the set variable calculation). GetField is unnecessary in this case. GetField is usually used to obtain a value using only text (or a calculation producing text) to specify the field. Otherwise it is superfluous, as you can just point at the field (which gets the value directly). From FileMaker Help (kind of a riddle, but it says what it does in its two uses; neither of which you need right now ( - ) Suppose you have the fields Arrow and Target. Arrow contains the text string Target, and Target contains the text string Bullseye. • GetField(“Arrow”) returns Target. Notice the use of quotation marks around Arrow to indicate the literal string is the fieldName parameter. • GetField(Arrow) returns Bullseye. Notice the absence of quotation marks to indicate the value stored in the Arrow field is the fieldName parameter.
Newbies Slisciani Posted October 19, 2010 Newbies Posted October 19, 2010 Perfect! It worked! Thank you!
Recommended Posts
This topic is 5149 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 accountSign in
Already have an account? Sign in here.
Sign In Now