Check email address against list

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…

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

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
end if

This prints false:

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

b = "abc"

While this prints true:

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

b = "abc"

Perfect! adding ToString solved the issue.

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

Thanks for the speedy response!