5 Replies Latest reply on May 6, 2013 12:13 AM by ekettu

    Issue with Scripting Attachment of Document


      I've come across an issue that i believe i know what the problem is, just don't know how to go about correcting it.


      I've created a layout where a user either selects an email address (from dropdown) or types on in. They also have a drop down to select a document they would like to email. The list of documents is linked to a table that has the document name and path.


      In the script to send, i'm taking the document path and storing it in a variable to use in the email, but the document never makes it as an attachment in the email as you can see in the screenshot below:




      My assumption is that the issue has to do with the formatting of the document path.


      I then changed the variable of $DocPath to be:


      "filewin:/: & Substitute ( EmailDocs::DocPath ; "" ; "/" )


      However, filemaker does not like this and states that "The text constant does not end with a quotation mark."


      Am i correct in my assumption, and if so, how can i format the path properly.

      If i am incorrect, why is the document not attaching?

        • 1. Re: Issue with Scripting Attachment of Document



          If you don't have a typo in your post, the variable definition for $DocPath should be:


          "filewin:/" & Substitute( EmailDocs::DocPath ; "\" ; "/" )


          I also assume that the S: drive letter is properly mapped for you and anyone who will be running this script. You might want to think about using UNC file paths instead of drive letters.



          • 2. Re: Issue with Scripting Attachment of Document

            Yes, it was a typo.


            Everyone will always have an S: drive as there is a script that runs when a domain user logs in make sure that it exists, if not, it creates it.


            I'll try with a UNC path and see what happens.

            • 3. Re: Issue with Scripting Attachment of Document

              I was able to work around it and get the file attached by storing the DocPath in the table as filewin:/S:/Temp/Shared_Docs/filename.pdf rather than trying to manipulate the path in the script.

              • 4. Re: Issue with Scripting Attachment of Document

                Hi Matt


                Just for your information, I think I can see why your original path calc failed ...


                "filewin:/" & Substitute( EmailDocs::DocPath ; "\" ; "/" )


                The 'Backslash' character has 'escaped' the following 'double quote' - in other words the second 'double quote' has been converted into an 'in-line' 'double quote' and therefore your calc has unbalanced quotes - as per the error message.


                I think you need to add another 'backslash' to escape the original 'backslash' (Not at my machine at present, so I can't say I've tested this on your formula);


                "filewin:/" & Substitute( EmailDocs::DocPath ; "
                " ; "/" )


                This might help for 'next time ...'


                Best wishes - Alan Stirling, London UK.

                • 5. Re: Issue with Scripting Attachment of Document



                  I combining Field data and attachment file to same email - this way.

                  This has been tested with Mac and iPad versions


                  #Check that the is a file in Document-folder - name is not empty

                  #This will avoid fault in script if there is no file


                  If[GetAsText [ ("Table::FieldName") not equal ""]


                  #Get folder path - this will get Container Path

                  Set Variable [$filePath; Value:Get(TemporaryPath)]


                  #Get file name - attached file name

                  Set Variable [$fileName; Value:GetAsText ("Table::FieldName")]


                  #Create path to file = folder path + file name

                  Set Variable [$attachFile; Value:GetAsText ($filePath)&""&GetAsText($fileName)]


                  #Export file from path - only export don't create email

                  Export Field Contents["Table::FieldName; "$attachFile"]


                  #End If


                  #Send email and attach $attachFile file to

                  Send Mail [....


                  Choose Attach file and Specify File look after $attachFile


                  I don't have need to attach multiple files, but basicly if create variable

                  $fileName2 and $attachFile 2 with other container "Table::FieldName 2"

                  and add these to Specify File look after $attachFile2.


                  The files should be added to same eMail-body


                  Also text can be added in to body - by using Calculation-functions in Send Emal [...