Pages

Search This Blog

Tuesday, June 14, 2011

Reading Sharepoint Audience using object model

Use the follwing code snipt to read sharpeoint audience using object model

using (SPSite objSpSite = new SPSite("http://servername"))
{
// Get the audience manager
AudienceManager objAudienceManager = new AudienceManager(ServerContext.GetContext(objSpSite));

//Get the audience group
Audience objAudience = objAudienceManager.Audiences["HR"];

//Get the members list of the audience
ArrayList objUserInfoCollection = objAudience.GetMembership();

foreach(UserInfo userInfo in objUserInfoCollection)
{
// the user email of the respective audience group
string sUserEmail=userInfo.Email;
}
}

No comments:

Post a Comment