5 Replies Latest reply on May 9, 2012 4:27 AM by millie

    Script to insert name and subject automatically into email

    millie

      Title

      Script to insert name and subject automatically into email

      Post

      Hi - I am trying to set a script to automatically insert the required name and subject into an email where a pdf record is attached.

      I have used a script to save the required record to an external drive and to open and attach to an email.

      However, when I use the 'send email' function in the script, this opens a separate email.  I don't seem to be able to use this function either to attach the correct saved pdf email and then save to the external drive.

      My thinking was that I should set the script to save the pdf to the file, then set the function to 'send mail'.  But, in doing this I was not sure how to script the step where the email could retrieve the saved file - as each pdf saved has a unique name scripted in.

      Thanks

      Muir

      Script_email.jpg

        • 1. Re: Script to insert name and subject automatically into email
          philmodjunk

          Your script has a number of details that look to be a source of trouble. You have a go to related records step where the specified layout is <unknown>

          You have two extra End If steps--would think you'd get an error just trying to close the script editor.

          Go to Object[object name: "Press"]

          doesn't seem to be needed in your script unless it is tripping a script trigger by doing so.

          Once you have created and saved the PDF useing $Path as the designated variable for file name and location, you can add a Send mail step after the save as pdf step, click the attach file checkbox and type in the variable name. The mail sent by that script step will then attach the PDF to the email.

          • 2. Re: Script to insert name and subject automatically into email
            millie

            Thank you PhilModJunk for your words of wisdom - the major script errors have been corrected and the functions work well now...

            ....with the exception of inserting the client's email address into the 'To' field in the email.

            Should this be a calculation rather than a specify field?  I have a field for the client's email address but not sure how to set this as a calculation.

            Thanks!

            • 3. Re: Script to insert name and subject automatically into email
              millie

              Hi there - Can you tell me if there a limit to what you are able to insert as a subject line in the calculation?

              The calculation formula I entered for the pdf file to be saved was "Client Confirmation ref :" & FIELD FOR CLIENT NAME & "_" & FIELD FOR CAMPAIGN TITLE & "_" FIELD FOR CONFIRMATION REF

              This appeared to work but when I enter a similar formula for the subject line in the email, it always misses out the client name.

              • 4. Re: Script to insert name and subject automatically into email
                philmodjunk

                The two options for TO should produce the same results.

                I think the issue is involved with where this information ( and the client name ) are stored. I'm guessing that they are not stored in the "main confo" table, but a different table. If so, you need either a valid relationship between the two tables at the time Send Mail is executed or you'll need to modify your approach in order to access the needed data.

                Where is this data stored and what relationship, if any do you have between that table and "Main Confo"?

                • 5. Re: Script to insert name and subject automatically into email
                  millie

                  That worked a treat.  Many thanks PhilModJunk for your 100% brilliant answers, as always. Smile