Here is my code for searching contact by preferred mail.
using (XConnectClient client = SitecoreXConnectClientConfiguration.GetClient())
{
try
{
var queryable = client.Contacts
.Where(c => c.GetFacet<EmailAddressList>(EmailAddressList.DefaultFacetKey).PreferredEmail
.SmtpAddress != string.Empty).OrderByDescending(c => c.LastModified).WithExpandOptions(new ContactExpandOptions(EmailAddressList.DefaultFacetKey));
var enumerator = queryable.GetBatchEnumeratorSync(20);
while (enumerator.MoveNext())
{
if (enumerator.Current != null)
{
foreach (var contact in enumerator.Current)
{
if (contact.Emails() != null)
{
var email=contact.Emails().PreferredEmail.SmtpAddress;
}
}
}
}
}
catch (XdbExecutionException ex)
{
AnalyticsHelpers.SitecoreLogException(ex);
}
}
If I use here SmtpAddress == "[email protected]"
I dont get any contact. Though those contacts are showing in experience profile.
If I use SmtpAddress != string.Empty
I am getting lots of contacts and one of contact's email address is [email protected]
.
How to get only those contacts which preferred email address is [email protected]
?
Also after checking some code, I have found that if I find that even if I use SmtpAddress == "[email protected]"
the query still take this contact.