Sending email from script based on dates

Hi,

I have a couple of cases where I'd like to send an email based on dates and I wanted to see what the best way to handle this is. The first case is that I'd like to send an email one month before now() is equal to a DateTime memory tag value. In the second case, I'd like to send an email on the first day of each month. Essentially what I'm looking for is where this script should be and the logic to handle determining when to send the email. I figured I'd ask here first before trying something and having the emails being sent nonstop by accident. I can handle the email part of the script, it's more just how to handle the timing part of it that I'm looking for help with. If you need more specific details just let me know.

Thanks!

It's good that you're considering this possibility. I got the guys at the last place I worked to always give a clue in the from address field to help the IT guys track it down quickly. e.g.,
myActionName.myProjectName.myServerName@myPlant.myCompany.com

Since the script may be reused in different projects and the project may be copied from (test) gateway to (production) gateway you should script the myProjectName and myServerName to pick up their values automatically.

1 Like

Gateway event scripts are probably the best way of doing this. Especially for sending on the first of every month. You could use a scheduled event that runs on that specific schedule.

For the one that compares the current time to a tag, you could schedule it to run every morning, read the tag, and send the email only when the condition is met. (You could test with a logger in place of the email first, just in case).

2 Likes