6 Replies Latest reply on Dec 15, 2011 7:39 PM by Olex

    Auto birthday email

    sly_1

      Title

      Auto birthday email

      Post

      I have a birthday filed in my student record. I have the birthday email already setup and working.

      Is there a script that i can use that will auto check todays date against teh birthdate filed that will auto send email.

       

      example.

       

      birthday = 12/21/1996

      todays date = 12/21/2009

       

      when todays day/month match birthdays day month it will send a happy birthday email.

       

       

      Sly

        • 1. Re: Auto birthday email
          comment_1
            

          Try something like:

           

          Enter Find Mode []

          Set Field [  BirthDate ; Substitute ( Get (CurrentDate) ; Year ( Get (CurrentDate) ) ; "*" ) ]

          Perform Find []

           

           

          This needs a little more work in order to find leaplings on Feb 28 of a regular year.

          • 2. Re: Auto birthday email
            mrvodka
              

            You can have a script that fires every day either through a startup script or script trigger such as On Install Timer if you have FMP10 to find the people's records.

             

            Enter Find Mode []

            Set Field [ Birthday; Let ( d = Get ( CurrentDate ); Substitute ( d; Year ( d ); "*" ) ) ]

            Perform Find []

            • 3. Re: Auto birthday email
              sly_1
                

              Thank you. This works.

               

              It will find all records matching this search.

              How would I allow it to send an email to allrecords that matched the search.

               

              example.

               

              I have 10 birthdays today

              how would I have the script I created to auto send this email to all 10 records.

               

               

              Also,

              how would I get this script to auto run every time they open FM.

               

               

              thanx for all the help

              • 4. Re: Auto birthday email
                TSGal

                slyomega:

                 

                Thank you for your post.

                 

                Now that you found your records, you can add:

                 

                Send Mail [ Send via E-mail Client ; No dialog ; To: <Email field> ; etc. ]

                 

                This uses your default email application.  When setting up the E-mail script, select the option for "Multiple emails (one for each record in found set) "

                 

                There is a possibility that no birthdays occur, so we need to trap for that.  Therefore, change the entire script to:

                 

                Set Error Capture [ On ]

                Enter Find Mode []

                Set Field [ Birthday ; Let ( d = Get ( CurrentDate ) ; Substitute ( d ; Year ( d ) ; "*" ) ) ]

                Perform Find []

                If [ Get ( FoundCount ) > 0 ]

                   Send Mail [ Send via E-mail Client ; No dialog ; To: <Email field> ; etc. ]

                End If

                Set Error Capture [ Off ]

                 

                ---

                 

                Turning on error capture allows you to suppress the error message when no records are found.  We then check to see if there are some records, and if so, send out the emails.

                 

                If you want this to auto-run every time you open FileMaker Pro, pull down the File menu and select "File Options..."  Click the "Open/Close" tab (if not already selected), and under the section "When opening this file", put a check mark next to "Perform script" and select this script.

                 

                One additional problem that may occur is if this file is closed or crashes during the day, you don't want to send another message to everyone.  Therefore, you may want to create another field, gDate, a date field with global storage.  You can then evaluate against this field for today's date, and if it doesn't equal today's date, then perform the find.  After sending the emails, you can update this field to today's date.  That way when you open the file again on the same day, it won't continue with the script.

                 

                 

                If [ Get ( CurrentDate ) = gDate ]

                   Exit Script

                End If 

                Set Error Capture [ On ]

                Enter Find Mode []

                Set Field [ Birthday ; Let ( d = Get ( CurrentDate ) ; Substitute ( d ; Year ( d ) ; "*" ) ) ]

                Perform Find []

                If [ Get ( FoundCount ) > 0 ]

                   Send Mail [ Send via E-mail Client ; No dialog ; To: <Email field> ; etc. ]

                   Set Field [ gDate ; Get ( CurrentDate) ] 

                End If

                Set Error Capture [ Off ]

                 

                 

                -----

                 

                I hope this makes sense.  If you need clarification for any of the above steps, please let me know.

                 

                TSGal

                FileMaker, Inc. 

                • 5. Re: Auto birthday email
                  mrvodka
                     If this is a solution that is shared, I would probably use something like a log table to track what dates have been sent so that not everyone who logs in will send it again as globals are session specific.
                  • 6. Re: Auto birthday email
                    Olex

                    Another question on this topic:

                     

                    How can you set-up date range search and add it to

                    Set Field [ Birthday ; Let ( d = Get ( CurrentDate ) ; Substitute ( d ; Year ( d ) ; "*" ) ) ]

                     

                    I need to find birthdays that are coming up between 21 and 30 days from CurrentDate.

                     

                    Thanks