SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wonder how to get the email for a specific user. I want to send an email to the user that created a specific item in a list. I can get the user by using the following

    SPWebApplication webApplication = this.Parent as SPWebApplication;
    SPContentDatabase contentDb = webApplication.ContentDatabases[contentDbId];    
    SPList taskList = contentDb.Sites[0].RootWeb.Webs["Subsite"].Lists["Tasks"];
    foreach (SPListItem task in taskList.Items)
        String user = task["Author"].ToString();


Is there a way I can get the user email address from there?

share|improve this question
up vote 2 down vote accepted

I prefer to transfer the "author" field into a proper user type field. After that getting the email to the "SendEmail" workflow control is really simple:

 //Get the author field as a user
 SPFieldUserValue authorUser = new SPFieldUserValue(workflowProperties.Web, currentItem["Author"].ToString());

       //Set the email TO field like this
        sendCompletedEmail.To = authorUser.User.Email;
share|improve this answer
Please mark as answer if it work for you Carlos. – Anonymous Sep 30 '10 at 19:24

If you simply want to email the creator of an item it would be easiest to do this with a simple workflow.

To grab it in code you can connect to the UserProfileManager and load the user's profile based on the value of the author field.

share|improve this answer

At the end I did it like this.

String userName = task["Author"].ToString();
String user = userName.Split(new Char[]{';','#'})[0];
String email = contentDb.Sites[0].RootWeb.Webs["Subsite"].SiteUsers.GetByID(int.Parse(user)).Email;

task["Author"].ToString() returns a string that contains the user id and the display name separated by the string ";#".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.