1 2 3 Previous Next 36 Replies Latest reply on Jul 19, 2011 3:45 PM by philmodjunk

    Email found set

    thong127

      Title

      Email found set

      Post

      Hi Experts,

      anyone in the forum has a script for emailing found set?kindly share it to me thanks. I have field for materials, expiry date and retest date...I want that when i open my data base the script will send me an email reminding me about the expired materials and retest materials on that date. any help is highly appreciated. thank you very much

       

      thong

        • 1. Re: Email found set
          philmodjunk

          Simplest approach is to use Save As PDF to save a PDF of a report listing your found set. Then your email can be sent with this PDF as an attachment.

          It takes more scripting, but a simple table of text listing the data from you found set can be produced and included in the email body instead.

          • 2. Re: Email found set
            thong127

            Hi Phil,

            attached is the link of my sample. kindly help me with the script. thanks.

            http://www.4shared.com/file/K5ygNU9F/Email.html

            • 3. Re: Email found set
              philmodjunk

              I have questions:

              Why the loop to PDF and email one record at a time?

              Why not Set up the PDF layout for list view and make a single PDF of the entire found set to email?

              Observations:

              You have:

              Set variable [$ActiveEmail ; Value: EmailContactName]
              Set variable [$ActiveEmail ; Value: EmailContactEmail]

              Note how the value put in $ActiveEmail in the first step, is overwritten by the value stored in the second Set Variable step. Since the second step puts the actual email address in place, this is harmless, it's just that you could remove the first step and your script will produce exactly the same results.

              You have:

              Save Records as PDF [no dialog]

              It should read:
              Save Records as PDF [no dialog; "$FilePath"] ; Records being browsed]

              To make that change, double click the script step and type in: $FilePath (no quotes)

              You have:

              Send Mail [Send via E-Mail client; To: $ActiveEmail ; Subject: "Retest and Expired Materials"]

              Is should be changed to:

              Send Mail [Send via E-Mail client; To: $ActiveEmail ; Subject: "Retest and Expired Materials" ; "$FilePath"]

              To add the variable, click the attach file check box and then type in $FilePath (no quotes).

              • 4. Re: Email found set
                thong127

                Hi Phil,

                Here is my new Script now, but I cant make to run it correctly.

                Set Erron Capture [on]

                Go to Layout ["Email_Contact"(Email)]

                Show all Records

                Go to Record/Request/Page[First]

                Loop

                Set Variable[$ActiveEmail; Valuw:Email::ContactEmail]

                Enter Find Mode[]

                Go to Layout["Materials Layout"(Materials)]

                Set Field[Materials::Expiry Date, Month(Get(CurrentDate))+1

                Perform Find[]

                Set Variable[$found;Value:Get(Foundcount]

                if[$found>0]

                Set variable[counter;Value:1]

                Loop

                Set Variable[$names;Value:$names & GetNthRecord(Materials::Material Name; $counter) & "¶"

                Exit Loop If [counter = $found]

                Set Variable[$counter;Value:$counter + 1]

                Show Custom Dialog ["ATTENTION!!!! NEXT MONTH EXPIRING PRODUCTS"; "NEXT MONTH to be Retest & to be ExpiredPRODUCTS:¶"  & $names

                Go to Layout ["PDF View" (Materials)]

                Set Variable [$Filepath; Value:"Filewin" & Get(TemporaryPath0]

                Save Record as PDF[Restore; No dialog;""$FilePath""; Create email; Records being browsed]

                Send Mail [Send via SMTP Server; No dialog; To: $ActiveEmail; Subject: "Retest & Expired Materials", ""$FilePath""]

                Go to Layout [Materials Layout"(Materials)]

                Go to Record/request/Page/[Next; Exit after last]

                End loop

                End loop

                End If

                 

                Thank you for your help

                 

                • 5. Re: Email found set
                  philmodjunk

                  How doesn't it work?

                  Why do you use loops like this? (If this worked, it would send the same PDF over and over again, once for each record found in the materials table instead of just one Email. (If you find 5 materials, you'll send the email 5 times, but the attachment will list the same 5 materials each time.)

                  • 6. Re: Email found set
                    thong127

                    Hi Phil,

                    its not sending and email...just looping for a long time...and it will only stop when i press the escape kay on my keyboard.

                    • 7. Re: Email found set
                      philmodjunk

                      Note the missing dollar sign: likely a typo when you posted your script that isn't in the original but such a typo could give you an infinite loop:

                      Exit Loop If [counter = $found]

                      Set Variable[$counter;Value:$counter + 1]

                      Have you been able to send email via your SMTP server before? Perhaps by just using Send Mail from the File Menu?

                      To repeat: you need to remove a loop here. (the inner one) As written, each recipient would get multiple copies of the same email. I don't think you need any loop at all here if you use the "Multiple emails one for each member of the found set" option.

                      • 8. Re: Email found set
                        thong127

                        Hi Phil,

                        I check my script and they have a dollar ($) all the script you pointed out. i also removed the loop before (Set Variable[$names;Value:$names & GetNthRecord(Materials::Material Name; $counter) & "¶"). its okey now its not giving me infinite looping. but still cant send an email. thank you

                        • 9. Re: Email found set
                          philmodjunk

                          Have you been able to send email via your SMTP server before? Perhaps by just using Send Mail from the File Menu?

                          This will only work if you have access to an SMTP server and then only if it's configured correctly.

                          • 10. Re: Email found set
                            thong127

                            Yup, I can send email via our smtp server before.

                            • 11. Re: Email found set
                              philmodjunk

                              Just noticed you have ""$FilePath"" in both the save as PDF and Send mail steps. That suggests you have entered "$Filepath" in each of these steps instead of $FilePath. If that is the case, you need to remove the quotes.

                              • 12. Re: Email found set
                                thong127

                                I Still have no luck Phil

                                • 13. Re: Email found set
                                  philmodjunk

                                  As a test, clear the "no dialog" option in the send mail step and check to see what appears in the send mail dialog when you run this script.

                                  • 14. Re: Email found set
                                    thong127

                                    Hi Phil,

                                    I did your suggestion, but still theres no response when I wun the script.

                                    1 2 3 Previous Next