Check email address against list

studio

#1

Hi,
I’m doing something wrong here and I can’t figure out what. I have a csv file with a list of email addresses in it. I have a variable that has a single email address in it. If the email address appears in the csv file I want to do X, otherwise I want to do Y.

I’ve used Read Column in Excel to create a variable called VerfMail of type System.Collections.Generic.IEnumerable<System.Object>

I have a GenericValue variable called RequestorEmail

For the If statement, I’m using VerfMail.Contains(RequestorEmail), but this is always returning a FALSE - even if the email address appears in the list.

Is someone able to point me in the right direction please? Thanks in advance…


#2

Use “For each” Activity to “VerfMail” , and check each objects as string.
This way takes a little time , but reliable.


#3

I think this has to do with GenericValue not playing nicely with comparison to Object. Can you try using VerfMail.Contains(RequestorEmail.ToString) instead if you are sure that it contains only strings?

For example, this code throws compilation errors:

Dim a As Object
Dim b As GenericValue

a = "abc"
b = "abc"
If a = b Then
	console.WriteLine("equal")
Else
	console.WriteLine("unequal")
end if

This prints false:

Dim a As New List(Of Object)
Dim b As GenericValue

a.Add("abc")
b = "abc"
Console.WriteLine(a.Contains(b).ToString)

While this prints true:

Dim a As New List(Of Object)
Dim b As GenericValue

a.Add("abc")
b = "abc"
Console.WriteLine(a.Contains(b.ToString).ToString)

#4

Perfect! adding ToString solved the issue.

Condition now reads: VerfMail.Contains(RequestorEmail.ToString) and everything is working as expected.

Thanks for the speedy response!