Sharepoint 2010 Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint 2010       RSS Feeds

Get e-mail from "person or group" item

  Asked By: Aquake    Date: May 09    Category: Sharepoint 2010    Views: 14898

Hello, i have a list with user items and i would like to get the emailadress from the users listed in the list.

Something like
web.lists["My list"].items[0][Person].getEmail();

Anyone who knows the correct syntax?



2 Answers Found

Answer #1    Answered By: Sirisha Reddimasi     Answered On: May 10

I guess some thing you can try in this way. If listhaving a column for user id.
Then get user is using SPUser object and then you can get Email from SPUser Object.

SPUser user = new SPUser (Listitem);
user.Email --------------- will have email id.

Answer #2    Answered By: Aquake Bloep     Answered On: May 12

Thank you for your answer.
It is very probable your way will work.
In the mean time i found another way that worked well for me.

SPListItem listitem = properties.ListItem;
String Email = null;
SPFieldUser userFieldSalesManager = listitem.Fields["Created By"] as SPFieldUser;
SPFieldUserValue userValueSalesManager =(SPFieldUserValue)userFieldSalesManager.GetFieldValue(listitem["Created By"].ToString());
Email = userValueSalesManager.User.Email;

Didn't find what you were looking for? Find more on Get e-mail from "person or group" item Or get search suggestion and latest updates.
This post is locked for further answers.