# Send Email Script with parameter not working

**URL:** <https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 31, 2024, 6:21pm UTC](https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213 "2024-05-31T18:21:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [May 31, 2024, 6:21pm UTC](https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213/1 "2024-05-31T18:21:27Z")

</div>

I am currently trying to have an email sent if a tag reads in between certain values. I also want the email to contain the machine number that the tags are coming from. I have the machine number set as one of the parameters of the tags. This is the current code I am working with:

```python
if currentValue.value > 5 and currentValue.value < 10 or currentValue.value > 18 and currentValue.value < 20:
				
				body = '{ENumber}' + "had a yellow zone resul of:" + currentValue.value
				rec = ['ryan.craig@colder.com']
				
				system.net.sendEmail("smtp.dovercorporation.com", "BurstTesters@colder.com", "Burst Tester Caution", body, 0 , rec)

```

which is giving me this error:

([default]E398/E398/Test2BurstFinal, valueChanged) Error executing tag event script: Traceback (most recent call last): File "tagevent:valueChanged", line 26, in valueChanged TypeError: cannot concatenate 'str' and 'float' objects

I also tried this code:

```python

			if currentValue.value > 5 and currentValue.value < 10 or currentValue.value > 18 and currentValue.value < 20:
				
				body = str({ENumber}) + "had a yellow zone resul of:" + currentValue.value
				rec = ['ryan.craig@colder.com']
				
				system.net.sendEmail("smtp.dovercorporation.com", "BurstTesters@colder.com", "Burst Tester Caution", body, 0 , rec)
	

```

which is giving me this error:

([default]E398/E398/Test2BurstFinal, valueChanged) Error executing tag event script: Traceback (most recent call last): File "tagevent:valueChanged", line 26, in valueChanged NameError: global name 'E398' is not defined

Any idea how to fix this issue?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 31, 2024, 6:31pm UTC](https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213/2 "2024-05-31T18:31:30Z")

</div>

We have no way to know what line 26 is if you don't post at least 26 lines of your script 😄

But, it's pretty much guaranteed to be this line, or a similar one earlier:

```python
body = str({ENumber}) + "had a yellow zone resul of:" + currentValue.value

```

In **expressions** , you can just curly-braces to insert dynamic references to properties and tags. In **scripting** , you cannot - you are bound to the semantics of Python, because that's the language you're using.

So what you are _meaning_ to do, I assume, is read a sibling tag `ENumber`, but what you are _actually_ doing is trying to create a Python set literal with one member, the variable `ENumber`.... which (probably) doesn't exist in the local scope.

You need to use the `system.tag.readBlocking` function to read _any_ tag from scripting. The function returns a list of qualified value objects. So the most direct translation of this line would be something like this:

```python
qvs = system.tag.readBlocking(["[.]ENumber"])
ENumber = qvs[0].value
body = str(ENumber) + "had a yellow zone resul of:" + currentValue.value

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 31, 2024, 6:34pm UTC](https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213/3 "2024-05-31T18:34:38Z")

</div>

Also, you need to cast `currentValue.value` as a str, because it's apparently a float (based on your conditional checks).

```python
body = str(ENumber) + "had a yellow zone result of:" + str(currentValue.value)

```

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [May 31, 2024, 6:37pm UTC](https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213/4 "2024-05-31T18:37:46Z")

</div>

My mistake, yes the script I posted was line 26. This solution seemed to do the trick, thank you!

---

<div class="post-metadata">

**Author:** ![Ryan\_Craig](https://avatars.discourse-cdn.com/v4/letter/r/45deac/32.png) [@Ryan\_Craig](https://forum.inductiveautomation.com/u/Ryan_Craig)\
**Post date:** [May 31, 2024, 6:38pm UTC](https://forum.inductiveautomation.com/t/send-email-script-with-parameter-not-working/91213/5 "2024-05-31T18:38:04Z")

</div>

I noticed that, as well, after I made this post. Thanks for the help!
