本文整理汇总了C#中SPWeb.RunAsSystem方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.RunAsSystem方法的具体用法?C# SPWeb.RunAsSystem怎么用?C# SPWeb.RunAsSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPWeb
的用法示例。
在下文中一共展示了SPWeb.RunAsSystem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendEmail
/// <summary>
/// Send an email depending on the specified email information.
/// </summary>
/// <param name="web">The SharePoint Web.</param>
/// <param name="emailInformation">The email information.</param>
public void SendEmail(SPWeb web, EmailInfo emailInformation)
{
if (this.IsRecipientOverrideEnabled(web.Site.WebApplication))
{
var RecipientOverrideEmail = this.propertyBagHelper.GetWebApplicationValue(web.Site.WebApplication, RecipientOverridePropertyBagKey);
emailInformation.Body = GetRecipientOverrideMessage(emailInformation) + emailInformation.Body;
emailInformation.To.Clear();
emailInformation.To.Add(RecipientOverrideEmail);
emailInformation.CarbonCopy.Clear();
emailInformation.BlindCarbonCopy.Clear();
this.logger.Warn("An email with the subject line '{0}' is being sent with the recipient override email address '{1}'.", emailInformation.Subject, RecipientOverrideEmail);
}
var headers = EmailHelper.GetEmailHeaders(emailInformation);
web.RunAsSystem(elevatedWeb =>
{
var logMsg = string.Format(
CultureInfo.InvariantCulture,
"Sending email using the web '{0}' with the following headers... to: '{1}', cc: '{2}', bcc: '{3}', subject: '{4}'",
elevatedWeb.Url,
headers["to"],
headers["cc"],
headers["bcc"],
headers["subject"]);
this.logger.Info(logMsg);
// Send the email
SPUtility.SendEmail(elevatedWeb, headers, emailInformation.Body);
this.logger.Info("Email Sent.");
});
}