I need to get an email out of emails in my C # application. I have a user ID or first name And last name is please suggest me a suitable way.
Thanks
public string GetEmaiId (string user id) {string email = String.Empty; Directory finder objsearch = new directory finder (); String strrootdse = objsearch.SearchRoot.Path; DirectoryEntry objdirentry = New directoryInterior (stratotdus); Objsearch.Filter = "(and (cn =" + userId + ") (objectClass = user))"; Objsearch.SearchScope = System.DirectoryServices.SearchScope.Subtree; Objsearch.PropertiesToLoad.Add ("cn"); Objsearch.PropertyNamesOnly = true; Objsearch.Sort.Direction = System.DirectoryServices.SortDirection.Ascending; Objsearch.Sort.PropertyName = "cn"; Search ResultCollection colresults = objsearch.FindAll (); Foreach (search keywords objresult in coloretsults) {email = objresult.GetDirectoryEntry (). Properties ["Mail"]. Value.ToString (); } Objsearch.Dispose (); Return email; }
Comments
Post a Comment