Returning selectedStringValue in a script to use as email address

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

What I return is in the form of u’’ 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’?

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

1 Like

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

[u’’] including the brackets and single quotes. When it was used as a from address in the following code, it would not send:“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))

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

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



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

I am at Ignition Platform 7.9.10