9 Replies Latest reply on Jun 20, 2013 8:32 AM by philmodjunk

    How to send letters by email

    sundown

      Title

      How to send letters by email

      Post

            

           Phil, I need help. I thought I had the emails working, but found a problem I can't understand. While testing, I am sending the pdf file to my own email address. Running the script from the Host FM database file on my iMac & checking my mail on the iMac & macbook, all is well. The email is received with the attachment. I also get one of the multible  pdf files (not all) in the folder where the file is located. When I re-email the same files, the same pdf file replaces the previous one.

           I enable this file on the Filemaker Network.  I  went to my macbook & opened the file from the remote network. I tested the email script from the remote file by sending the email to my same email address. I checked the email , and the pdf attachment is not there. The attachment seems to only work correctly from the host computer & not from the remote network file. Do you know what is happening?

           Here is the script I am using:

      Set Variable [ $FileName ; Value: "Invoice.pdf" ]

      Save Records as PDF [ Restore; No dialog ; "$FileName" ;Current record ]

      Set Variable [ $PDFPath ; Value: Get (DocumentsPath) & $FileName ]

      Send Mail [ Send via E-mail Client ; No dialog; To: "user1@abc.com" ; Subject: "Invoice" ; Message: "Test" ; "$FileName" ]

        • 1. Re: How to send letters by email
          philmodjunk

               You'll need to save the letter as a PDF then attach the PDF to the email as an attachment. Either that you construct a plain text calculation for putting the same data in the body of the email (It won't reflect the design of your layout if you use that method). The third alternative is to explore email plug ins that offer more options for what you put in the body of your email.

               Here's a link on setting up a script to save a PDF that can get you started with the first step: Found Sets to PDF with unique file names

          • 2. Re: How to send letters by email
            sundown

                 Thanks for the info Phil. I am just getting started on this and the link helps. I will do the PDF of the letter.

            • 3. Re: How to send letters by email
              philmodjunk

                   You can then take the same $Path variable that you used to save the PDF to attach the PDF to your Email.

                   Open the Dialog for the Send Mail script step. Click the Attachment check box and type in the exact name of the path variable that you used.

              • 4. Re: How to send letters by email
                sundown

                      

                     Thanks Phil. I set my script up like thisexample & the emails did not have an attachment. I changed the attachment from "$PDFPath" to "Invoice.pdf", & the email attachment worked. Am I missing something or should I leave ie this way? 

                     Set Variable [ $FileName ; Value: "Invoice.pdf" ]
                     Save Records as PDF [ No dialog ; "$FileName" ; Records being browsed ]
                     Set Variable [ $PDFPath ; Value: Get (DocumentsPath) & $FileName ]
                     Send Mail [ Send via E-mail Client ; To: "user1@abc.com" ; Subject: "Invoice" ; Message: "Test" ; "$PDFPath" ]

                      

                      

                • 5. Re: How to send letters by email
                  philmodjunk

                       Try using $FileName instead of $PDFPath, You aren't saving your PDF to the Documents folder unless your database file is also located in the documents folder.

                  • 6. Re: How to send letters by email
                    sundown

                         Thanks Phil. That works. 

                    • 7. Re: How to send letters by email
                      sundown

                           One more minor point. I have a field to register which clients have an Email address. I now use "Is Empty (field)" function to check the Email address field & produce a "1" or "0". This function does not work if someone gets a "none" or a space entered in the Email address field (it happens).

                           Is there a FM function that better detects a proper email address so i don't get the rejection only after I try to send an email to "none"?

                      • 8. Re: How to send letters by email
                        sundown

                              

                             Phil, I need help. I thought I had the emails working, but found a problem I can't understand. While testing, I am sending the pdf file to my own email address. Running the script from the Host FM database file on my iMac & checking my mail on the iMac & macbook, all is well. The email is received with the attachment. I also get one of the multible  pdf files (not all) in the folder where the file is located. When I re-email the same files, the same pdf file replaces the previous one.

                             I enable this file on the Filemaker Network.  I  went to my macbook & opened the file from the remote network. I tested the email script from the remote file by sending the email to my same email address. I checked the email , and the pdf attachment is not there. The attachment seems to only work correctly from the host computer & not from the remote network file. Do you know what is happening?

                             Here is the script I am using:

                        Set Variable [ $FileName ; Value: "Invoice.pdf" ]

                        Save Records as PDF [ Restore; No dialog ; "$FileName" ;Current record ]

                        Set Variable [ $PDFPath ; Value: Get (DocumentsPath) & $FileName ]

                        Send Mail [ Send via E-mail Client ; No dialog; To: "user1@abc.com" ; Subject: "Invoice" ; Message: "Test" ; "$FileName" ]

                        • 9. Re: How to send letters by email
                          philmodjunk

                               Please see my response to your new thread. The "relative path" that you are using which puts the PDF in the same folder as where you database file is located isn't likely to be a valid bath when accessing the database from a different computer.