# Email script no longer works - Cannot coerce value array

**URL:** <https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966>\
**Category:** Ignition\
**Created:** [April 29, 2015, 1:33am UTC](https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966 "2015-04-29T01:33:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [April 29, 2015, 1:33am UTC](https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966/1 "2015-04-29T01:33:44Z")

</div>

I have an email report that stopped working a few months ago. Ive just got around to trying to get it working again and Ive found for some reason Im getting an error related to the email attachment “Cannot coerce value '[array”

this code worked without issues a few months back and im not sure what has changed.

here is a snippet of the code

` path = "//Public//Equipment//Email Charts//GR1.jpg"
  GR1_chart = system.file.readFileAsBytes(path)
  GR1_name = "Grinding Robot history.jpg"
  system.net.sendEmail("owa.abc.com", "Equipment_Monitor@abc.com", "Daily Runtime Report for Belt Grind", body, 1, recipients,[GR1_name],[GR1_chart])`

here is the compact version error:

[code]Traceback (most recent call last):

File “”, line 183, in

File “”, line 181, in main

java.lang.ClassCastException: java.lang.ClassCastException: Cannot coerce value ‘[array(‘b’, [-119, 80, 78, 71, 13, 10, …-126])]’ into type: class [Ljava.lang.String;

Ignition v7.7.4-beta2 (b2015030909)  
Java: Sun Microsystems Inc. 1.6.0\_31  
[/code]

---

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [April 30, 2015, 4:56pm UTC](https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966/2 "2015-04-30T16:56:44Z")

</div>

Can anyone help me out on this? I was going to call in and open a ticket later - but hoping it was something that could be resolved here.

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [April 30, 2015, 6:05pm UTC](https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966/3 "2015-04-30T18:05:24Z")

</div>

Have you tried using print statements to help debug this? It looks like you have a parameter that is the wrong type.

```auto
print type(body)
print type(recipients)
print type(GR1_name)
print type(GR1_chart)
```

Compare the printed type to the data types for the parameter of system.net.sendEmail and see if there is a mis-match.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [April 30, 2015, 9:02pm UTC](https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966/4 "2015-04-30T21:02:42Z")

</div>

cja7928, it’s the hazard of using betas. 😊

I’m going to guess that beta-2 was when “priority” was added to system.net.sendEmail, and it got added in the middle, between “to” and “attachmentNames”. It was caught before the RC, but made it into the beta.

I would suggest upgrading to the final release version of 7.7.4. If you can’t do that, change your script to use the keyword-style invocation.

---

<div class="post-metadata">

**Author:** ![cja7928](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@cja7928](https://forum.inductiveautomation.com/u/cja7928)\
**Post date:** [May 2, 2015, 8:42pm UTC](https://forum.inductiveautomation.com/t/email-script-no-longer-works-cannot-coerce-value-array/9966/5 "2015-05-02T20:42:28Z")

</div>

Thank you very much. Ill see if our IT guys are willing to upgrade to 7.7.4
