How do I get the email address of the author of a SharePoint list item?

user1017882 picture user1017882 · Jun 29, 2012 · Viewed 11.4k times · Source

As title says, I have access to the current listitem - and it's easy enough to get the author/created by name - but how do I retrieve the e-mail address of the author in C# from the object model?

Thanks.

Answer

Rich Bennema picture Rich Bennema · Jul 2, 2012

You can get the SPUser from a SPFieldUserValue object:

SPFieldUserValue userValue = 
    new SPFieldUserValue(web, item[SPBuiltInFieldId.Author].ToString());
SPUser user = userValue.User;
string email = user.Email;