使用wss 3.0获取电子邮件管理员

时间:2012-05-10 12:57:19

标签: visual-studio-2010 sharepoint-2010 wss

如何使用wss 3.0从网站集管理员那里获取所有电子邮件?

1 个答案:

答案 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