4 Replies Latest reply on Aug 24, 2015 2:14 PM by talkersw

    Simple Email Script Help

    talkersw

      Hi guys, I am a complete new user to filemaker. I  am looking to export the current record (and all fields), then auto send the email to a user specified from the field (which i can get to work). There will be a button to trigger the script, but I cannot get the script written correctly. I tried Export Records and the Send Mail, etc.; however, there was nothing attached to the email. I just want the data in an email and have it send without me looking at it. Please help and provide context to your answer please.

      Edit_Script_“email”__emailtest_.png

        • 1. Re: Simple Email Script Help
          Mike_Mitchell

          Just exporting records and then sending an email doesn't put anything in the body of the email. You need to put the text of the fields into the body of the email. You can use a calculation to do this. As an example:

           

          "Dear " & table::firstName & ":¶¶" &

           

          "Thank you for your purchase of " & table::productName & ". We appreciate your business. This is your invoice.¶¶" &

           

          List ( product::productName ) & "¶" &

           

          "Total:  $" & invoice::total & "¶¶" &

           

          "Please do not hesitate to call if you have any questions."

           

          Obviously, you would use your own statement.

           

          If you want to send an actual attachment, then you would attach the exported records (although a Save as PDF is probably more to the point). However, you'll want to be sure you save it to a consistent path using Get ( TemporaryPath ) or Get ( DocumentsPath ) and then attach it using the Attachment checkbox in the email dialog.

           

          HTH

           

          Mike

          1 of 1 people found this helpful
          • 2. Re: Simple Email Script Help
            talkersw

            Thanks Mike,

             

            This works. I am not sure what drives the required saving of the file and the extra mail draft; however. If you have any feedback on that, please let me know. I thought Export Records [no dialog] would prevent that.

            • 3. Re: Simple Email Script Help
              Mike_Mitchell

              I'm not certain what you mean by "the required saving of the file". If all you want to do is send an email, there's no file saving required. Just construct the body of the email in the Body field and send it. (In other words, the Export Records step in your original script isn't needed.)

               

              If you want to send an attachment, then, of course, you would need to create that file first. But that's not "extra"; it's just a requirement of sending an attachment. Can't send something that doesn't exist.

              • 4. Re: Simple Email Script Help
                talkersw

                I realized that shortly after asking. The solution came out great. I will have to learn some more advanced scripting in the future, but this fits my current needs.