Solved

Email sent already Counter?


Badge

Hi There, I have a workbench that sends an email 24 hours after a certain event occurs. However, the email gets sent everytime the workbench runs and I do not want to spam people, so I only want to send ONE email every 24 hours --but I want to be able to run the workbench often (to check for new events and send out email reminders after 24 hours to those people). --How can I check to see if an email has ALREADY been sent out? That way I only send them ONE email per time period (24 hours in this case) even if the workbench runs many times per day? THANKS FOR ANY HELP HERE! Lewis

icon

Best answer by chrisatsafe 11 May 2022, 19:35

View original

7 replies

Badge +2

Hi @louielou1234​ ,

One way you could get this done would be to add a workspace after the email action that simply writes a text file with the date the email was sent - you can pass this in using the output key from the Email Action and a published parameter in the workspace (or a date timestamp in the workspace would work as well). Something like this would be sufficient:

imageThen in the workspace you want to run over and over again, read in that Text File and utilize a Tester with Automation Writers to check the number of hours since the last email was sent (if >= 24 hours, send it to a New Email automation feature type and if <= 24 hours send it to an Already Emailed automation feature type).

imageThis way you can simply connect the emailer to the New Email feature type in the Automations canvas.

image

Badge

Hi Chrisatsafe,

 

This information really helped me to solve my issue. And thank you so much for also including an example workspace --it made it so much easier to follow the logic of your explanation. Just amazing. Thank you again!!!

Badge +2

Hi Chrisatsafe,

 

This information really helped me to solve my issue. And thank you so much for also including an example workspace --it made it so much easier to follow the logic of your explanation. Just amazing. Thank you again!!!

Hi @louielou1234​ ,

Glad I was able to help :D

Badge

Hi @louielou1234​ ,

One way you could get this done would be to add a workspace after the email action that simply writes a text file with the date the email was sent - you can pass this in using the output key from the Email Action and a published parameter in the workspace (or a date timestamp in the workspace would work as well). Something like this would be sufficient:

imageThen in the workspace you want to run over and over again, read in that Text File and utilize a Tester with Automation Writers to check the number of hours since the last email was sent (if >= 24 hours, send it to a New Email automation feature type and if <= 24 hours send it to an Already Emailed automation feature type).

imageThis way you can simply connect the emailer to the New Email feature type in the Automations canvas.

image

Hi there again chrisatsafe,

 

Just a quick followup question -- the workbench I created using your solution works perfectly when run manually from FME Desktop, but when it is published to FME Server on a Schedule the .txt gets properly Written to (with new timestamp values) but it seems like it is NOT Server does not Read from the file -- for it will just keep sending out new emails. I tried many fixes, such as upgrading FME Server and Desktop to the latest versions, and used a UNC path to reference the .txt file, checked folder permissions for Server, etc... but no luck. Any ideas on what the problem could be? Thanks very much for any thoughts.

Badge +2

Hi there again chrisatsafe,

 

Just a quick followup question -- the workbench I created using your solution works perfectly when run manually from FME Desktop, but when it is published to FME Server on a Schedule the .txt gets properly Written to (with new timestamp values) but it seems like it is NOT Server does not Read from the file -- for it will just keep sending out new emails. I tried many fixes, such as upgrading FME Server and Desktop to the latest versions, and used a UNC path to reference the .txt file, checked folder permissions for Server, etc... but no luck. Any ideas on what the problem could be? Thanks very much for any thoughts.

Are you seeing any error message in the log file? Are you also seeing the same behaviour if you write to the default resource data folder?

 

If you could also send a screenshot of how your automation is currently configured that would be great. If you'd like to take this offline I can create a case and we can proceed via email if that is preferred - just let me know.

Badge

Hi there again chrisatsafe,

 

Just a quick followup question -- the workbench I created using your solution works perfectly when run manually from FME Desktop, but when it is published to FME Server on a Schedule the .txt gets properly Written to (with new timestamp values) but it seems like it is NOT Server does not Read from the file -- for it will just keep sending out new emails. I tried many fixes, such as upgrading FME Server and Desktop to the latest versions, and used a UNC path to reference the .txt file, checked folder permissions for Server, etc... but no luck. Any ideas on what the problem could be? Thanks very much for any thoughts.

Hi,

Yes!...could we take this offline with a ticket?...I could then provide more detailed information on the workbench. Thank you!...but briefly to answer your question...

 

Well there are 2 (non-fatal) errors that show up in both Server and Desktop Logs. One is a Python warning that we hope is not important because we can not upgrade our server OS just yet (we currently run FME Server and FME Desktop on a Windows Server 2016 Standard box). The Python error is:

 

Python: There is a known Windows bug that may cause instability when using Python in the current locale. Please update to Windows 10 version 2004 and greater, or to Windows Server 2022

 

And the other error is puzzling because we seem to have the correct syntax in the Transfomer (to convert UTC time to our local PST time)... The error is:

 

AttributeCreator: Failed to parse '' as a datetime value. For FME datetime syntax, please see (...and the URL links provided lead to missing SAFE.com 404 errors) and there is also some related error messaging lines later on that say:

 

Failed to evaluate expression '@TimeZoneSet(utc)'. Result is set to null

Failed to evaluate expression '@TimeZoneSet(local,convert)'. Result is set to null

 

but the transformer seems to output the converted time just fine and is this: @TimeZoneSet(@TimeZoneSet(@Value(assigneddate),utc),local,convert).

 

But other than these (minor?) warning errors, there are no warnings about not being able to Read or Write from the .txt file with the timestamps.

 

 

Badge +2

Hi there again chrisatsafe,

 

Just a quick followup question -- the workbench I created using your solution works perfectly when run manually from FME Desktop, but when it is published to FME Server on a Schedule the .txt gets properly Written to (with new timestamp values) but it seems like it is NOT Server does not Read from the file -- for it will just keep sending out new emails. I tried many fixes, such as upgrading FME Server and Desktop to the latest versions, and used a UNC path to reference the .txt file, checked folder permissions for Server, etc... but no luck. Any ideas on what the problem could be? Thanks very much for any thoughts.

Got it, I just escalated this post to a case so our team can look into it. With regards to the failed to evaluate expression error, that seems like the DateTime Function inside the AttributeCreator is not cooperating. Try replacing the date-time function you are performing in the AttributeCreator with one of the DateTime Transformers (i.e. converter ). You might have to first format the date-time as UTC but the team will be able to look into this after you send in the resources you mentioned. Please follow up with that info to the email you will be receiving shortly.

Reply