I am trying to email to all the contacts (from a local FM solution) and attach a photo (stored locally) but the email is sent without the JPG file.
The Family Trip 2014.JPG is located at Documents folder.
You may want to try using the Get(DocumentsPath) function to set the file path to a variable.
Check you please help check if the steps are correct?
Are you doing this on Mac or PC? You might want to try using a Case() statement in conjunction with the Get(SystemPlatform) function (1 = Mac, 2 = PC) to evaluate if you are doing this work on a Mac or PC, and then append "filemac:" or "filewin:" accordingly in the front of your file path, instead of the "file:" which, by "relative path" Filemaker means (I think) relative to the location of the database on the machine, so you might be getting the path wrong depending on where you have the database stored.
Also, it might be helpful for debugging to watch the values of your variables when they are set by using the Script Debugger and the Data Viewer when you run the script.
This looks OK; but note that you can check this yourself quite easily.
If the Send Mail step is set to work "With dialog: On", it will open a new mail in your client using the provided text(s) and attachment, but not send it; so you can inspect it at your leisure to fine-tune the step parameters (and simply discard that unsent mail).
btw, there is no need to declare a global $$variable in your script if you won't be using that variable after the script has finished. Better use a local $variable to keep things tidy.
In my experience, "Send Mail" attaches files just fine without adding any "file:" prefix, at least on the Mac (which seems to be what James is using).
@ James: Andrew's suggestion of using Script Debugger & Data Viewer is very sensible – if you have FileMaker Pro Advanced, that is. If you don't, and you still want to inspect the variable values, you can e.g. use the old school method of using dialog boxes to display them.
Is it possible that the original set up would have worked but your jpeg is a really massive file that is too large to email by normal means? There are file size limits after all--set not by Filemaker but by the email account and ISP's involved.
I ask that because the original settings in the dialog should have worked provided that the file had the name shown and the file reference was correct. And simply using the add file option should guarantee that it is correct.
I am doing this on Mac. And I have run debugger and also turned on the perform dialog. But if I just go down to the very basic, which is one script step, it still does not work.
One script step, I mean I am viewing the record, there is a button called "Email" and this button has only the Send Mail script step and the attachment is on my local Mac, (documents or desktop folder).
I have turned on the perform dialog and also try changing the attach file. Anyway, the attach files are about 100kb size.
While replying to the above messages and doing the trial and error..... the send mail script step is working now. What was last performed was the changed of attach file and everything is resolved. Thank you all for your thought.
My next task is to upload this to FMS and user can send mail but attach file come from their local. Hope I can do it...
Oh..... the send mail script step is not working if I turned off perform without dialog (means I want to see the mail before actually sending it out), now that it is working, so I turn on the perform without dialog (automatically send without asking user interaction) and the attachment is not sent with the email.
The script is entirely the same, the change is just whether to perform with or without dialog, and it affects the attachment being sent or not. Is this a bug somewhere? What should I do now?
What I am referring to is:
This WILL work (I can see the attachment before sending it out)
This WILL NOT work (email is sent automatically without user interaction)
Sorry for the bad explanation previously and couldn't find the way to edit it, hence this additional reply
I have hosted the same file onto FMS 14 and run the script (after modified to adjust to the server environment). I notice the same behavior and the email will be sent with the attach PNG file is the script is paused (i.e. perform with dialogue) and no attachment will the script run without user interaction.
I have also tested using FMPA version 13 and 14 to upload the solution to FMS 14 and the result is the same.
I repeat the above on another Mac running El Capitan and the result is the same. My current Mac is OS Sierra.
There is always no issue on iOS since it will prompt you to click send whether or not the script is perform with dialog.
I have also removed all my mail clients and recreat were th just one iCloud client on the Mac that is having El Capitan but to no avail.
Please help if you know someth about this problem.
It is a "great" discovery (also disappointing) that it works perfectly fine when I execute it on my Windows computer. The client is FM Pro 13 running on Windows 7 (Parallel Desktop on my existing iMac). I created a mail client (@hotmail.com) and the email with attachment is sent to various recipient with different domain (meaning it can send to the recipients from gmail.com, me.com, hotmail.com etc).
So I thought I should change my default mail client from @me.com to @hotmail.com on my iMac, but I am wrong again. No matter what mail client I am trying to use, the PNG is not attached with the mail.
Is this a Mac Mail issue or FileMaker bug?
I have another similar hosted solution (which I developed more than a year ago) that does the same email (with attachment) and it was working perfectly on this same iMac but it is not working now unless I run it from Windows PC.
Do you think you can help me with my issue as updated below? What additional information should I submit that you think it will be helpful for this community?
I currently use windows and I don't know why it isn't working for you.
You might try two things just in the spirit of trying all issues:
Try launching your email client first (if you are sending via email client).
Try putting a small pause of a few seconds using the Pause/Resume script step just before the send mail script.
The one odd thing that I've noticed from the beginning of the thread is that you have a simple file name in quotes. It seems odd that a script would send out attachments that always have the same file name. Wouldn't there be a different file name each time that you run this script?
Thank you for taking the time to reply.
To clarify, it is working on my Windows computer perfectly.
Mail client (Mac Mail is always launched when my Mac starts).
I had the pause for 3 seconds script step but it does not help with the problem.
I am not entirely sure that I understand about your last point on the "file name in quotes...." I attach the script below for your checking
The solution is currently hosted and I am happy to attach whatever I can for your checking.
I am aware that this script is not perfectly written and thanks for pointing out.
The file is upload to the Global table, Forte_Image field by dragging a PNG into he field whose field definition is in the above attachment.
If the script is performed with dialog,
The email will be sent with the attachment
Really appreciate your time and effort for this issue. Please correct me if I make anything mistake in my work here.
I currently use windows and I don't know why it isn't working for you.
Thanks and sorry (for the misunderstanding) and that I (as well as my client) are "annoyed" by this issue lately.
He has 260 such emails to send and it is extremely embarrass to request him to click the send button 260 times or ask him to use Microsoft Windows computer.
Thanks again, you are awesome!
I would like to close this thread (unresolved) as I am told that this is a known issue and this is no fix in the foreseeable future.
You may may check out this Mail attachment is missing when trying to send mail using FileMaker Pro on OS X | FileMaker if you need a workaround.
Thank up all.
Retrieving data ...