4 Replies Latest reply on May 9, 2011 8:51 AM by jessieleah

    Send Mail Script

    jessieleah

      Title

      Send Mail Script

      Post

      Is there a way to make the Send Mail script to work even if every field it refers to isn't filled in?  Like we have crew people that get assigned to a project.  Sometimes there are two people and sometimes there are six people.  I wrote a script that bascially says if the status of a project is changed to planned then send email to all the crew people.

      It seems if every crew email address isn't filled in with something, then the script doesn't work.  Is there a way around this?

        • 1. Re: Send Mail Script
          philmodjunk

          What option are you using to send the email? Are you sending one email at a time or using the "Multiple Emails" one for each record in found set option?

          Either way, there are a number of ways that you can use to omit the records where the email address is empty. One simple way, is after you pull up the crew records as your found set, enter find mode, put an asterisk in the email address and choose Constrain Found Set and that will omit the records that do not have an email address.

          • 2. Re: Send Mail Script
            jessieleah

            The way I have the script set up is - omit all records except the one being viewed so one record is shown.  Then there are 7 fields - one for the project manager and 6 for the crew.  So it would be one email for the one record found.  The problem being if any of the fields referenced for the Send Mail script is empty, the script fails.  

            These are the field names:

            To: Work Orders::PMEmail

            CC: Work Orders::CrewMemberEmail1 & P & Work Orders::CrewMemberEmail2 & P & Work Orders::CrewMemberEmail3 & P & Work Orders::CrewMemberEmail4 & P & Work Orders::CrewMemberEmail5 & P & Work Orders::CrewMemberEmail6

            The "P" being a paragraph maker used in the calculation window

            Does something have to be present in the email fields in order for the script to successfully generate an email?  I should mention we are using Entourage 2008 and Outlook 2011 for Mac.

            • 3. Re: Send Mail Script
              philmodjunk

              Check to make sure you have the correct list delimitter for your emails. For most such lists, you need either a semi colon or a comma to separate the emails:

              Substitute ( List ( Work Orders::CrewMemberEmail1 ; Work Orders::CrewMemberEmail2 ; Work Orders::CrewMemberEmail3 ; Work Orders::CrewMemberEmail4 ; Work Orders::CrewMemberEmail5 ; Work Orders::CrewMemberEmail6 ) ; ¶ ; "; " )

              List drops out the blanks, but produces a list of values separated by returns just like your original expression. The substitute function then replaces the returns with semi-colons to use as the delmitter. In your case, you may need to use a comma instead.

              • 4. Re: Send Mail Script
                jessieleah

                AWESOME, AWSOME, AWESOME!  That totally worked.  OMG!  If you were standing here I would totally hug you!