# Returning selectedStringValue in a script to use as email address

**URL:** <https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744>\
**Category:** Ignition\
**Created:** [March 2, 2020, 6:43pm UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744 "2020-03-02T18:43:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkruper](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lkruper](https://forum.inductiveautomation.com/u/lkruper)\
**Post date:** [March 2, 2020, 6:43pm UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/1 "2020-03-02T18:43:12Z")

</div>

emailFrom = [event.source.parent.getComponent(‘Dropdown Email From’).selectedStringValue]

What I return is in the form of u’person@gmail.com’ with a “u” preceding the value. I realize this is a list, as a regular expression won’t let me directly edit this ‘u’ off the name. I am still learning python, and I know it is my ignorance here.

So, how do I return the value without the ‘u’?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [March 2, 2020, 6:55pm UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/2 "2020-03-02T18:55:49Z")

</div>

the ‘u’ at the beginning just lets you know it’s a unicode string. You can just use it like you normally would.

---

<div class="post-metadata">

**Author:** ![lkruper](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lkruper](https://forum.inductiveautomation.com/u/lkruper)\
**Post date:** [March 2, 2020, 9:28pm UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/3 "2020-03-02T21:28:18Z")

</div>

Thanks, I have a work around. What is returned was actually something when converted to string was actually:

[u’person@gmail.com’] including the brackets and single quotes. When it was used as a from address in the following code, it would not send:

system.net.sendEmail(smtpProfile=“Google SMTP”,fromAddr=emailFrom, subject=emailSubject, body=emailBody, html=1, to=emailrecipient1)

So I used regular expression substitutions to remove the extraneous characters and it works.

It does not seem to be considered a string because in the following code, unless I converted to string, I would get an error that the function did not work on a list object. The string does come from a Dropdown component.

emailFrom = re.sub(‘u’’,’’,str(emailFrom))  
emailFrom = re.sub(’[’[]]’,’’,str(emailFrom))

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [March 3, 2020, 4:35am UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/4 "2020-03-03T04:35:05Z")

</div>

I’m curious about how you got the ‘u’. I’m doing a test where the output from selectedStringValue of a dropdown and is just the string itself

---

<div class="post-metadata">

**Author:** ![lkruper](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lkruper](https://forum.inductiveautomation.com/u/lkruper)\
**Post date:** [March 3, 2020, 4:40am UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/5 "2020-03-03T04:40:37Z")

</div>

Have you added any data to the dataset? I added three email addresses in a single Label column.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [March 3, 2020, 5:01am UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/6 "2020-03-03T05:01:54Z")

</div>

yes

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/70a66cdd5937f48d7faec1931252ea60af68c3c4.png)

Where you tested the output? From where you called it?

---

<div class="post-metadata">

**Author:** ![lkruper](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lkruper](https://forum.inductiveautomation.com/u/lkruper)\
**Post date:** [March 3, 2020, 5:05am UTC](https://forum.inductiveautomation.com/t/returning-selectedstringvalue-in-a-script-to-use-as-email-address/32744/7 "2020-03-03T05:05:16Z")

</div>

I am at **Ignition Platform** `7.9.10`
