I was using SPUtility.ResolvePrincipal to resolve the email address but it only seems to work if the user is already in the User Information List. Is there any way I can resolve users based on email if they do not yet exist in the User Information List?
I have 1,000 emails in the list that need to be resolved to people.
There are about 60,000 users in the User Profile Service Application. How would you go about matching them?
Current code follows:
using (SPSite site = new SPSite("http://sp2010/sites/TheSite"))
{
if (properties.ListItem["CONTACT EMAIL ADDRESS"] != null)
{
string email = properties.ListItem["CONTACT EMAIL ADDRESS"].ToString();
SPWebApplication webApp = site.WebApplication;
SPPrincipalInfo pi = null;
pi = SPUtility.ResolvePrincipal(webApp, null, email, SPPrincipalType.User, SPPrincipalSource.Windows, true);
if (pi != null)
{
UserProfile vmProfile = findUser(pi);
if (vmProfile != null)
{
SPUser user = properties.Web.EnsureUser(pi.LoginName);
SPFieldUserValue userName = new SPFieldUserValue(properties.Web, user.ID, user.Name);
properties.ListItem["Vendor Manager"] = userName;
}
}
}
}