9 Replies Latest reply on Jun 25, 2012 2:38 PM by hsimon

    Send mail as pdf mode

    hsimon

      Title

      Send mail as pdf mode

      Post

      good afternoon I have a doubt as sending an email filemaker THROUGH capturing the presentation in pdf
       after many attempts and made it to the sending by mail, but I save it to PDF and displays two windows in
       me tells me that a s size of the presentacionno is right and the other to my target file does not exist,
       anyone can tell me exactly like the script to make this aforementioned action or else the calculation for fm
       send the data to ask a email, I hope to help me as I delay too long in my bd for those details that I choke

      I hope you have a nice day

        • 1. Re: Send mail as pdf mode
          Sorbsbuster

          Can you?:

          - print the report to pdf
          - send an e-mail with an attachment

          If you cannot do those steps, let us know.

          If you can do those steps then I assume your problem is that Filemaker says it cannot find the file to attach.

          If that is what is happening, then put a pdf file on your desktop, and set the e-mail to attach it.  If the e-mail sends correctly, then we only need to show you how to pick up that file path by using a variable.

          • 2. Re: Send mail as pdf mode
            Abhaya

            hi

            I think you have to catch that file name  in variable by

            set variable[var=getfilename()]

            then just use this variable with the perform pdf script.

             

            Hope you will get your solution

             

            Thanks

            abhaya

            • 3. Re: Send mail as pdf mode
              GuyStevens

              I made you a post this morning but apparently that didn't work so I'll try again.

              I made a little send mail script in one of my demo files, maybe you can look at it and try and copy it.

              Just look at the scripts and try the last one.

              It makes a pdf file on your desktop and sends that file as an attachement.

              You could also make a variable name so all your pdf's are stored and you can store them somewhere else as well, or in a folder on your desktop.

              http://dl.dropbox.com/u/18099008/Demo_Files/BillsMonthly.fp7

              • 4. Re: Send mail as pdf mode
                GuyStevens

                This is what the script actually looks like:

                Send mail script

                • 5. Re: Send mail as pdf mode
                  hsimon

                  Good afternoon, I'm new to filemaker and cause me some problems and scripts that I could not understand how the script "send mail pdf"
                  I could help understand step by step the script, you find it in the layout "invoices" Thanks for your help in this post, thanks

                  • 6. Re: Send mail as pdf mode
                    hsimon
                    DaSaint, one thing I read the script did not understand shipping mail but i failed to identify as active, it is automatic or activated by a button, and other questions in the script in the word "$ filename" is a command?
                    many thanks for providing time to read this post
                    • 7. Re: Send mail as pdf mode
                      GuyStevens

                      I'll try and break down the script:

                      There are 4 steps in my sript.

                      Go to layout:

                      This step takes you to the layout that you want to turn into a pdf.
                      If you want to make an invoice you should have made a layout that looks like an invoice but that's mostly white so it can be printed.

                      Set Variable

                      This creates the filename. The filename that Filemaker needs to save or attach a file to a mail.
                      A variable always needs two values,
                      - the first one is the name, this is so you can use this variable later on.
                      A variable is like a value that filemaker remembers for the duration of the script.
                      In this case the name of the variable is:
                      $Filename
                      A variable always has a $ sign in front of it, sometimes you need a persistent variable that can be used after the script ends and then you give it two dollar signs: $$Filename
                      - The second item you need for a variable is the actual value. In this case we are creating a filename. So the value of our variable called $Filename will be something like: file:c:/DaSaint/Database/Invoice.pdf

                      But that creates a problem if we have multiple users, they might not all have that folder, and some of them might be using a mac computer that doesn't even have a c:/ drive.

                      So we are using a get parameter called "Get (DesktopPath)"
                      This works both on PC and on Mac and gets you the location of the desktop.

                      Get (DesktopPath) returns our location but we need to add "file:" on the front and the actual name of the pdf document at the back.

                      So that becomes:

                      "file:" & Get ( DesktopPath ) & "PDF Document.pdf"

                      Now this only an example and you could make the filename the invoice number or anything else. You could also save it in a folder on the desktop and then all your invoices would be stored there.

                      Save records as PDF

                      This step actually saves the PDF. And here we use this $Filename variable to tell Filemaker where to save the PDF.

                      Send Mail

                      Send mail sends the mail and has the $Filename variable in the "Attach file" option so it knows exactly what file to attach to the mail.

                       

                      There, I hope that makes it clearer.

                      If you are trying to attach an invoice to the mail you will be needing a few extra steps in your script.

                      You will need to start on the invoice layout and set the Invoice ID as a variable. (I hope your Invoice table has an ID field that's a number field with Auto Enter Serial Value)
                      Then go to the invoice print layout and perform a find to find this Invoice ID so you end up with a found set showing only one invoice. Then you can turn that invoice into a pdf and mail it.

                      That script would look like: (starting on the invoice layout)

                      Set Variable [$InvoiceIdVariable ; Invoice::Id]
                      Go To layout [InvoicePrint]
                      Enter Fine Mode [Clear pause box]
                      Set Field [Invoice::Id ; $InvoiceIdVariable]
                      Set Error Capture [On]
                      Perform Find
                      Create Variable [$Filename ; "file:" & Get ( DesktopPath ) & "PDF Document.pdf"]
                      Save Records As Pdf
                      Send Mail

                      If you want to attach this to a button you create a button on your layout, right click it, go to "Button Setup" and choose "Perform Script.

                      Then you define the above script to be the script that runs.

                      • 8. Re: Send mail as pdf mode
                        GuyStevens

                        DaSaint, one thing I read the script did not understand shipping mail but i failed to identify as active, it is automatic or activated by a button,

                        I don't really understand that. Where do you see shipping mail?

                        And what do you mean with "to identify as active"?

                        • 9. Re: Send mail as pdf mode
                          hsimon

                          many thanks for your time have helped me