3 Replies Latest reply on Dec 1, 2015 2:25 AM by weedonpaul

    how can I email something in a container field?

    weedonpaul

      Hi all

       

      A few parts to this question:

       

      I have a container field in invoices that holds a PDF of the invoice to send out. I want to have a button called send that sends the pdf via attachment in an email. Whats the best way to do this as the way I do it by hand is to export the said pdf and then attach that to the email.

       

      Secondly If I can automate all this, when it opens up the email, is there any way that I can get it to put the text in already and the email address?

       

      Thirdly, I'm not sure if it's possible to do this, some of the users have multiple email addresses for different clients, is there a way of specifying the from address?

       

      thanks

      Paul

        • 1. Re: how can I email something in a container field?
          mikebeargie

          To export and attach the email, just script a variable and attach the variable in the "attachment" section of the send mail script step.

          Set Variable [ $file ; get(temporarypath) & getAsText(table::container) ]

          Export Field Contents [ table::container ; $file ]

          Send Mail

          (specify "$file" in your attachment box in the send mail step)

           

          Also in the send mail script step you can calculate the text that appears in the subject and body lines of the email.

           

          Also, if you want multiple email addresses, than you can calculate it separated by semicolons or commas, like so:

          table::email1 & ";" & table::email2 etc..

           

          Lastly, make sure to choose "email client" from the send email script step so it opens the email with the default email client, and also UNcheck the "perform without dialog" option to make sure that it brings the email up before it is sent.

           

          Send Mail

          • 2. Re: how can I email something in a container field?
            keywords

            You can script all of this. Your script would need at least the following steps:

            •     Set Variable—here you would define a path for the exported pdf, probably utilising Get(TemporaryPath)

            •     Export Field Contents—to actually export the PDF using the variable specified above as the export path

            •     Send Mail—where you can specify all the components of the email: To/CC/Bcc/Subject/Message/Attachment

             

            A couple of notes re the above:

            1.     Using Temporary Path means that you don't end up with extraneous copies of the PDF outside of your database, because FM creates and then destroys the temp version when it no longer requires it

            2.     With the provisos you have of alternate addresses etc, you might want to leave the perform without dialog option unchecked in the Send Mail step, so that you can tweak the email case by case.

            3.     The choice of From address is more likely controlled by your email program rather than FM, but you might be able to manage that via a calc.

            • 3. Re: how can I email something in a container field?
              weedonpaul

              thank you so much guys.