2 of 2 people found this helpful
Mike Duncan has a cool technique where you can zip multiple containers into a single file:
If you read up on the documentation for the send mail script step:
Two important notes from that:
FileMaker WebDirect does not support the Attach File option. FileMaker WebDirect also does not support the Perform without dialog option when sending mail via an email client.FileMaker Server scheduled scripts support sending mail via SMTP. However, if you attach a file, that file needs to be in a folder that FileMaker Server is allowed to export to. For more information, see Get(DocumentsPath) function.
What I normally do for user emails that need attachments from webdirect, is create a "queue" table in filemaker that has the email details (to,from,attachment container, subject, body). Then I run a server scheduled script that will process that queue, sending via SMTP.
Back to that first link, you can modify that CWP so that it generates the zip file directly to your server's documents folder, and that way you will have the zip file accessible for attaching to the email. If you name it the same thing each time you can force it to overwrite the old file (as to not fill up your server documents folder with old attachments)
Since you said you ideally want the server to run it anyways automatically, you can probably skip the WebDirect part all together and just perform all the actions you need on the server.
So to recap:
1) Generate zip file of container contents. You can use Insert From URL to trigger the PHP that generates the zip to execute.
2) Send email using SMTP, attaching the generated zip file from the documents folder.
Thanks. I'll take a look at it although I want this feature accessible to the FM Pro users as well as ipad users. I'm not sure of the implications there as I'm only just starting with Webdirect and have no PHP experience. Just to be a bit clearer - I want to send, as an example, 10 separate emails to 10 separate suppliers each with their own PDF from a container associated with their supplier record. ie. I need the server to loop through the selected suppliers and email the attachment. As always, it's the FM server access to that container field that is my challenge.
If you already have the PDFs in container fields, you can use the Base Elements plugin on the server (no plugin required for the end user) to export the container field using the "BE_ExportFieldContents" function.
Export the PDF to the documents folder, then you can attach it to an email and send via SMTP.
This would need to run on a script on the server, which you can kick off with a Perform Script on Server step. You might pass it a parameter with the ID of the record to find, export the PDF and send the email(s).
Would that work better?
I literally just found reference to the Base Elements plugin in these forums 40 minutes ago when I searched for 'export container contents server' !! Perfect. Thankyou Mike! I had investigated BE a few nights ago but didn't find their function wiki so couldn't confirm it would export containers. My second look this morning revealed all.
Thanks again. Off to make it work now
Thanks Mike - I was looking for a solution to this problem (sending PDF from server side script) a couple of weeks ago, but wasn't satisfied with the solutions I found at the time. Base Elements plugin sounds like the ideal solution. Chris
I have this exact same issue where I'm trying to create and send pdf file via a server script utilizing an smtp server.
At first, I had the pdf being created on the Get (temporary path) but I've changed it to Get (document path).
It doesn't work either way. I suspect it a permissions issue, right?
rtor451, that is NOT the same issue.
This thread is discussing emailing the contents of a container field, something that is already generated.
Save as PDF is not a supported script step for a filemaker server scheduled script.
There are two ways around this:
1) setup a "robot" filemaker pro machine that will generate a PDF to a container field on demand.
2) setup a PHP script that will "insert from URL" a PDF file into a container field on demand.
#2 is outlined well here:
#1 can be seen here:
And the documentation for "Save Records as PDF", stating that it's not compatible with server scheduled scripts, can be found here:
You are correct Mike. this is not the same issue. I never checked to see if the Save as PDF script step was compatible on the server. That clears it up. Thanks.
If I can get my server to attach what's in our container fields, that would be huge!
We use server side scripts for lots of reporting. The big downfall is the lack of attachments.
I tried adding this to one of our server reporting scripts that uses SMTP:
Our server has a "D" drive that holds that data. Can I point one of the variables to "D", export the container there, and then attach it?
We are using fms14 and will be moving to 15 in the next couple of weeks
It's pretty easy once you have the Base Elements Plug in (Free).
Let me know if you want some help?
Thank you. I like 'pretty easy'
I loaded the Base Elements plug in on our server.
I'm solid on the FM sending email with SMTP on the server. Using the BE functions is a challenge. The support page is a bit beyond me.
I could certainly use some help with how to use BE to get an attachment into a SMTP email.
I have re-read your post and the one stumbling block might be accessing the D:drive. From memory I had to use the filemaker document path because the server cannot access other directories beyond this one. In other applications I have worked around that by running a robot or slave FM Pro instance on the server so that it can access other drives (dropbox for example). I also run a VB script (Windows machine) to delete the PDF's every night.
File path was truncated in the SS above. I might be showing my ignorance but this was what worked on a Windows server...:
"C:\Program Files\FileMaker\FileMaker Server\Data\Documents" & Char(92) & $filename