13 Replies Latest reply on Jun 1, 2014 8:46 PM by keywords

    Attachment to e-mail in FM12/13 not working

    CarlEarl

      I had a DB that would import a PDF and send it to a list of subscribers as an attachment to an e-mail. Worked fine in FM 11. Updated the DB to 12/13 and the attachment nolonger goes. I have checked that nothing has changed in how the PDF is imported into the contaner field. The script has not changed. But when the e-mail goes out there is no Attachment.

       

      Has anyone else see this problem?

        • 1. Re: Attachment to e-mail in FM12/13 not working
          mikebeargie

          you can't send multiple attachments in one email if that is what you're trying to do.

           

          Not sure that you're use of the GetAsText() function works with the way container storage changed in FM12.

           

          I usually set a file path, like:

          "file:" & get(temporarypath) & "attachment.pdf"

           

          and use the export field contents script step to dump the attachment to a temporary location.

           

          Then the same variable I use to export I use as the attachment. Has always worked in 12/13 without issue, with the note that it only supports one attachment.

           

          Plugins allow you to send multiple attachments if that is needed.

          • 2. Re: Attachment to e-mail in FM12/13 not working
            keywords

            Mike is quite right. GetAsText ( ) will give you a lot more data than just a file name, unless it is stored within the field—ie. using storing a reference only, or any external storage setting. Therefore you willl need to parse out the name of the attachment. In FM13 you can use the GetContainerAttribute (  ) function as follows:

            GetContainerAttribute ( <yourfieldnamehere> ; "filename" )

            • 3. Re: Attachment to e-mail in FM12/13 not working
              CarlEarl

              I may have not mad it clear. Im not sending multible attachments I send one PDF per e-mail. When I bring the PDF into FM I bring it in not just referance. So It should create an e-mail, attach the PDF and send it out. It works perfict in FM 11 When I upgrade the database to 12 it stopped attaching the file.

              • 4. Re: Attachment to e-mail in FM12/13 not working
                rgordon

                You can not attached the contents of a container field to an email.  You need to export the file from the container.  I don't see an Export Field Contents script step in your script.  To attach the file to the email, you then need to specify the path to the exported file.

                • 5. Re: Attachment to e-mail in FM12/13 not working
                  CarlEarl

                  This is a real bummer. It could be done in FM11.  I wander why they would break that. Its not worth the re-write right now so I will jsut keep FM 11 around.

                  • 6. Re: Attachment to e-mail in FM12/13 not working
                    rgordon

                    If the script worked in 11 it should work in 12.  You might have a bad file reference.  Without an export field contents script step, you script should not work in Fm 11. Can you show the complete send mail script step?

                    • 8. Re: Attachment to e-mail in FM12/13 not working
                      keywords

                      I stand corrected by rgordon. Your script needs an ExportFieldContents step, eg:

                       

                      Set Variable [ $$attachment; GetAsText ( <yourContainerField> ]
                      Export Field Contents [ yourTableName::yourContainerField; “$$attachment” ]
                      Send Mail [ yourChosenSettings ; Attachment: “$$attachment” ]

                      Set Variable [ $$attachment; Value:"" ]

                       

                      NOTE: The above will work just as well if you use a local variable ( single dollar sign – $attachment ). Then you can do away with the last step above, as the variable nae will not persist once the script completes.

                      • 9. Re: Attachment to e-mail in FM12/13 not working
                        rgordon

                        I'm fairly certain your script worked in FM 11 because you either stored the PDF as a reference to the file (which you stated that you did not do) or the original PDF was in the same folder as the filemaker file.  The script will not work if the PDF is stored in the container (not a reference) and the original PDF is not in the same folder as the FileMaker file.  The script should still work in FM 12 if the above conditions are met. 

                        • 10. Re: Attachment to e-mail in FM12/13 not working
                          keywords

                          For my own interest I played around with this issue  and attach a demo file which achieves CarlEarl's purpose—WITHOUT an ExportFieldContents step, I might add, contrary to advice by rgordon and a previous post of mine.

                           

                          The email script is configured to work in both FM12 and FM13, in all the following cases: (1) no storage settings, file stored in field; (2) no storage settings, file stored as reference only ; (3) storage set to external(secure) ; (4) storage set as in 3 above, but overidden with file stored as reference.

                           

                          It all tested OK on my system, so I attach the file for anyone interested.

                           

                          CarlEarl: I trust this encourages you to persist with your original plan to upgrade to FM12/13!

                          • 11. Re: Attachment to e-mail in FM12/13 not working
                            rgordon

                            I tested the file and it worked but if I renamed the original file or deleted the original file, the script no longer worked.  The email could not find the attachment.  It looks like the script is attaching the original file, not the file in the container field.

                            • 12. Re: Attachment to e-mail in FM12/13 not working
                              CarlEarl

                              Thanks guys. I did some testing and even though I did not have the reference only checked, it seems thats what FM 11 was only refering to the PDF. If I moved the database after I imported the PDF it lost it. That told me it was only storing the reference after all.

                               

                              I have upgraded the DB and added the export you recomended and it does work fine. Thanks for your help.

                              • 13. Re: Attachment to e-mail in FM12/13 not working
                                keywords

                                You say: "… added the export you recomended …"

                                 

                                I hope you took note of my May 30 post and the attached file which showed that an export step is not really needed.