Checking DisplayTo , DisplayCC against an valid e-mail address

Hey Everyone,

Id like to know if anyone would ever needed to compare message fileds DisplayTo, DisplayCC against a valid e-mail address.
MessageInfoCollection messages = folder.GetContents();
foreach (var message in messages)
{
if (message.DisplayTo.Contains("email@gmail.com"))
Console.WriteLine(“Found it”)
}

@cesarngxp4r,

I have tried understanding your requirements but have not been able to completely understand them. Can you please elaborate in details so that I may proceed further to help you.

Hey,

Looks like that only representative names are displayed on those message fields ( DisplayTo, DisplayCc) , like “Cesar Garcia” and not "cesarng@gmail.com" for instance.
Is there any way to compare values using email address instead of names ?

@cesarngxp4r,

I have tested on of PST on my end and and DisplayTo and DisplayCC fields contain the email along with email. Can you please share the PST file that you are using on your end along with used sample code.

Sure give me your e-mail and i´ll send to you

@cesarngxp4r,

You may send that privately to me by clicking on my user name in post and selecting Message option. Please notify me here in this thread too once you have shared private message.
image.png (15.6 KB)