Compare a list of mails, using subjects with list of subjects stored in list of string

Hey all,

I want to compare a list of mails, using subjects with list of subjects stored in list of string.
I tried using a LINQ something like this - listMailMessage.AsEnumerable().Where(Function(mail) listSubjects.AsEnumerable().Where( Function(x) mail.Subject.ToString.ToLower.Trim.Contains(x.ToString.ToLower)) ).ToList

but this doesn’t work and gives error. - value of type enumrable(string) cannot be converted to Boolean.
Any help is appreciated.

(from m in listMailMessage
Let chk = listSubjects.Any( Function(x) m.Subject.ToString.ToLower.Trim.Contains(x.ToString.ToLower))
Where chk
Select v= m).ToList

Hi @Karan_Zaveri ,

Try this:

listMailMessage.AsEnumerable().Where(Function(mail) listSubjects.Any(Function(x) mail.Subject.ToString.ToLower.Trim.Contains(x.ToString.ToLower))).ToList

Regards,

2 Likes

thank you for your response, but it had an end of expression is expected error.

thanks for the response, it worked.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.