如何使用wss 3.0从网站集管理员那里获取所有电子邮件?
答案 0 :(得分:0)
尝试:
private string[] GetEmails(SPWeb web)
{
List<string> emails = new List<string>();
Guid siteID = web.Site.ID;
Guid webID = web.ID;
using (SPSite site = new SPSite(siteID, SPUserToken.SystemAccount))
{
using (SPWeb web1 = site.OpenWeb(webID))
{
SPUserCollection admins = web1.SiteAdministrators;
foreach (SPUser admin in admins)
{
emails.Add(admin.Email);
}
}
}
return emails.ToArray();
}
请注意,SiteAdministrators要求上下文用户为site collection auditor。