# ExecuteAndDistribute sending duplicate emails since upgrade to V8 from V7.9

**URL:** <https://forum.inductiveautomation.com/t/executeanddistribute-sending-duplicate-emails-since-upgrade-to-v8-from-v7-9/28167>\
**Category:** Ignition\
**Created:** [September 11, 2019, 1:08pm UTC](https://forum.inductiveautomation.com/t/executeanddistribute-sending-duplicate-emails-since-upgrade-to-v8-from-v7-9/28167 "2019-09-11T13:08:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gloweware](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@gloweware](https://forum.inductiveautomation.com/u/gloweware)\
**Post date:** [September 11, 2019, 1:08pm UTC](https://forum.inductiveautomation.com/t/executeanddistribute-sending-duplicate-emails-since-upgrade-to-v8-from-v7-9/28167/1 "2019-09-11T13:08:14Z")

</div>

I have a gateway script triggered on a tag (SMMain/TriggerReportProduction) that used to only send 1 email, but since upgrading to V8 from V7.9, I have started to receive 2. I started to see this issue with V8.02 and have since upgraded to V8.03.  
Here is my script, I hope that someone will see my mistake.  
I have added logging to make sure that the email IF statement is only being called once. Log info follow the script.

Thanks.

```auto
> 
> logger = system.util.logger("TestTriggerReport") 
> #logger.info("Info to log") 
> #logger.error("Error to log")
> start_time = system.date.format(system.date.now(), "yyyy-MMM-dd HH-mm-ss")
> logger.info("Start Report at " + start_time)
> 
> logger.info("Starting TestTriggerReport")
> 
> report_time = system.date.format(system.date.now(), "yyyy-MMM-dd HH-mm")
> filename = "Production Summary " + report_time + ".pdf"
> #Publish report to PDF file
> pdf_settings = {"path":"C:\\Ignition Reports", "fileName":filename, "format":"pdf"}
> #Email PDF to distribution list
> email_settings = {"to":["gloweware@gmail.com"], "smtpServerName":"EmailServer", "from":"gloweware@gmail.com", "subject":"Production Report " + report_time, "attachmentName":filename}
> 
> 
> trigger_report = system.tag.read("[default]SMMAIN/TriggerReportProduction").value
> if trigger_report:
> #Executes and distributes the report to a PDF
> save_time = system.date.format(system.date.now(), "yyyy-MMM-dd HH-mm-ss")
> logger.info("Saving Report at " + save_time)
> system.report.executeAndDistribute(path="ProductionReport", project="Reports_V2", action="save", actionSettings=pdf_settings)
> 
> trigger_email = trigger_report and system.tag.read("[default]SMMAIN/EmailReportProduction").value
> if trigger_email:
> # Executes and distributes the report to an email address.
> # FYI: The email server is set up on the gateway via the web interface
> email_time = system.date.format(system.date.now(), "yyyy-MMM-dd HH-mm-ss")
> logger.info("Sending Report at " + email_time)
> system.report.executeAndDistribute(path="ProductionReport", project="Reports_V2", action="email", actionSettings=email_settings)
> 
> #Send a handshake back to SMMAIN in all cases
> system.tag.write("[default]SMMAIN/TriggerReportProductionHS",1)
> 	
> done_time = system.date.format(system.date.now(), "yyyy-MMM-dd HH-mm-ss")
> logger.info("Finished Report at " + done_time)

```

Log Info:

| TestTriggerReport | 11Sep2019 06:32:10 | Finished Report at 2019-Sep-11 06-32-10 |
| --- | --- | --- |
| TestTriggerReport | 11Sep2019 06:32:10 | Starting TestTriggerReport |
| TestTriggerReport | 11Sep2019 06:32:10 | Start Report at 2019-Sep-11 06-32-10 |
| TestTriggerReport | 11Sep2019 06:32:08 | Finished Report at 2019-Sep-11 06-32-08 |
| TestTriggerReport | 11Sep2019 06:32:06 | Sending Report at 2019-Sep-11 06-32-06 |
| TestTriggerReport | 11Sep2019 06:32:05 | Saving Report at 2019-Sep-11 06-32-05 |
| TestTriggerReport | 11Sep2019 06:32:05 | Starting TestTriggerReport |
| TestTriggerReport | 11Sep2019 06:32:05 | Start Report at 2019-Sep-11 06-32-05 |

---

<div class="post-metadata">

**Author:** ![gloweware](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@gloweware](https://forum.inductiveautomation.com/u/gloweware)\
**Post date:** [October 2, 2019, 3:56pm UTC](https://forum.inductiveautomation.com/t/executeanddistribute-sending-duplicate-emails-since-upgrade-to-v8-from-v7-9/28167/2 "2019-10-02T15:56:45Z")

</div>

Since the original post, I have:  
Backed up gateway  
Uninstalled Ignition  
Renamed the Ignition folder in Program Files to \_old  
Installed 8.0.4  
Restored gateway from backup

I still get the 2 emails.

---

<div class="post-metadata">

**Author:** ![gloweware](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@gloweware](https://forum.inductiveautomation.com/u/gloweware)\
**Post date:** [October 3, 2019, 1:00pm UTC](https://forum.inductiveautomation.com/t/executeanddistribute-sending-duplicate-emails-since-upgrade-to-v8-from-v7-9/28167/3 "2019-10-03T13:00:37Z")

</div>

Figured this out.  
After upgrading to 8.0.4, my script started to log duplicate entries, so that was useful.  
What I did find was my IF statements were triggering on both High and Low states.  
What used to work doesn’t anymore, so I have updated my script with ‘== 1’ test conditions.

What used to work:  
if trigger\_report:

is now changed to  
if trigger\_report == 1:
