3 Replies Latest reply on Aug 27, 2016 3:27 PM by philmodjunk

    Can't send attachment in email




      I have a script that's running on Server that uses the Send Email script step, and for the life of me I can't get it to send an attachment. I'm declaring the path by using a $path variable that I believe is correct. Since the directory path was the folder where FileMaker stores server-side attachments, I thought perhaps it was a permissions problem or something, so I copied the file to the desktop and tried using Get(DesktopPath), and that didn't work either.


      My $path variable is constructed as follows...


      "file:/C:/Program Files/FileMaker/FileMaker Server/Data/Databases/RC_Data_FMS/Global DB/Files/Prepress/EST_Estimates/pdfContainer/" & "Estimate " & MiddleValues ( Get(ScriptParameter ) ; 6 ; 1 ) & ".pdf"


      I think the above syntax is valid, isn't it? I send a script result back to the client that was simply $path and the dialog box that popped up on the client looked like a good path.


      Any clues?

        • 1. Re: Can't send attachment in email

          All functions that end in "values" return text with a return as the last character and that is producing an impossible file name in your calculation as you get that return character followed by ".PDF"

          • 2. Re: Can't send attachment in email

            Hi Phil,


            Thanks for responding. Yes, I figured that out early on and thought I would do everyone a favor by leaving out my "substitute" function that stripped the carriage return. (Bad idea.) My actual $path variable looks like this...


            "file:/C:/Program Files/FileMaker/FileMaker Server/Data/Databases/RC_Data_FMS/Global DB/Files/Prepress/EST_Estimates/pdfContainer/" & "Estimate " & Substitute ( MiddleValues ( Get(ScriptParameter ) ; 6 ; 1 ) ; ¶ ; "" ) & ".pdf"


            And as I say, it doesn't work. The resulting emails are empty, no attachment.

            • 3. Re: Can't send attachment in email

              For a simpler expression, I'd use:


              GetValue ( Get(ScriptParameter ) ; 6 )


              This would eliminate the need for using Substitute as GetValue doesn't append that dratted return character.


              But that won't solve the immediate problem.


              I'd try this, If you can, go directly to the server computer such as via Remote Desktop. Open a local database with a container field in it directly on the Server computer and use Insert File to insert one of these files into the container field using the "by reference" option. Then use GetAsText ( YourTable::yourContainerField ) in the data viewer and compare the file path thus produced to the one produced by your calculation and look for any discrepancies.


              You might also move a copy of your file into the server computer's documents folder and then test the following calculated file path to see if it works:


              Get ( DocumentsPath ) & "Estimate " & GetValue ( Get(ScriptParameter ) ; 6 ) & ".pdf"


              If that works, you know that the file path to the left of "Estimate" has a problem. If this new path still does not work, you know that the part starting with "Estimate" isn't working for you.