Showing posts with label getting users from multiple people picker column. Show all posts
Showing posts with label getting users from multiple people picker column. Show all posts

Thursday, August 5, 2010

Getting users from multiple people picker column

Hi All,

I have been working on Sharepoint Portal quite a few requirements and one of it made me write a sample snippet for sending emails to all the "Assigned To"/"Cc" column users.

Now below is the code for reading all the users present in the multiple people picker column in which not only users but also groups could be selected.
***********************************
SPFieldUserValueCollection CcUsers = (SPFieldUserValueCollection)properties.ListItem["Cc"];
if (CcUsers != null)
{
foreach (SPFieldUserValue val in CcUsers)
{
if (val.User != null)
CcUserEmails += (val.User.Email + ";");
else
{
SPGroup grp = web.Groups.GetByID(val.LookupId);
foreach (SPUser user in grp.Users)
{
CcUserEmails += (val.User.Email + ";");
}
}
}
}
***********************************
This has resolved my coding.
Please post your comments or issues if any.