Well I incorrectly assumed that this was some flavor of a SPUser object, turns out the person field in a SPList is a special type SPFieldUser.
Well lets cut to the chase this is the code to access the email address of a SPListItem person column;
private bool EmailUser(SPListItem spListItem, string recordColumn, string subject, string message) { SPFieldUser spFieldUser = (SPFieldUser)spListItem.Fields[recordColumn]; SPFieldUserValue spFieldUserValue = (SPFieldUserValue)spFieldUser.GetFieldValue( spListItem[recordColumn].ToString()); if (string.IsNullOrEmpty(spFieldUserValue.User.Email) == false) return SPUtility.SendEmail(spListItem.Web, false, false, spFieldUserValue.User.Email, subject, message); else LogWrite("Error", string.Format("Send Email Error Message") ,spFieldUserValue.User.Name)); return false; }
2 comments:
Thanks!
Thank you! I wonder if anyone will ever reach the bottom of SharePoint Object Model...
Post a Comment