本文整理汇总了C#中SPListItem.VerifyFieldAccess方法的典型用法代码示例。如果您正苦于以下问题:C# SPListItem.VerifyFieldAccess方法的具体用法?C# SPListItem.VerifyFieldAccess怎么用?C# SPListItem.VerifyFieldAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPListItem
的用法示例。
在下文中一共展示了SPListItem.VerifyFieldAccess方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendEmailbytemplateEx
public static void SendEmailbytemplateEx(SPListItem item, SPListItem taskItem, List<NameValue> xvariables, SPListItem itemTemplate, string to, string cc, string variables)
{
List<EmailVariable> designerVariables = null;
List<EmailVariable> bodyVariables = null;
List<EmailVariable> subjectVariables = null;
string subject = string.Empty;
bool sendAsPlainMode = false;
string body = EnsureAbsoluteUrl(item.Web.Site, itemTemplate["Body"].ToString());
//string body = itemTemplate["Body"].ToString();
if (itemTemplate["Subject"] != null)
subject = itemTemplate["Subject"].ToString();
bodyVariables = Parser.GetAndSetVariablesFromTemplate(body, item, taskItem);
subjectVariables = Parser.GetAndSetVariablesFromTemplate(subject, item, taskItem);
designerVariables = Parser.GetVariablesFromDesigner(variables);
subject = Parser.SetValuesToContent(subject, subjectVariables, designerVariables);
body = Parser.SetValuesToContent(body, bodyVariables, designerVariables);
subject = ParseContentWithVariables(subject, xvariables);
body = ParseContentWithVariables(body, xvariables);
if (itemTemplate.VerifyFieldAccess("SendAsPlainText"))
{
sendAsPlainMode = Convert.ToBoolean(itemTemplate["SendAsPlainText"].ToString());
if (sendAsPlainMode)
body = body.ToPlainText();
}
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(item.Web.Site.ID))
{
using (SPWeb web = site.OpenWeb(item.Web.ID))
{
StringDictionary headers = new StringDictionary();
headers = buidEmailHeaders(taskItem, to, cc, subject, sendAsPlainMode);
SPUtility.SendEmail(web, headers, body);
}
}
}
);
}
示例2: SendEmailByTemplateWithAttachments
public static void SendEmailByTemplateWithAttachments(SPListItem item, MailAddress fromAddress, string to, string reply, string cc, SPListItem itemTemplate, List<Attachment> attachments, SPUser currentUser)
{
List<EmailVariable> bodyVariables = null;
List<EmailVariable> subjectVariables = null;
List<EmailVariable> designerVariables = new List<EmailVariable>();
StringDictionary header;
string subject = string.Empty;
bool sendAsPlainMode = false;
//string body = itemTemplate["Body"].ToString();
string body = EnsureAbsoluteUrl(item.Web.Site, itemTemplate["Body"].ToString());
if (itemTemplate["Subject"] != null)
subject = itemTemplate["Subject"].ToString();
bodyVariables = Parser.GetAndSetVariablesFromTemplate(body, item, null, null);
subjectVariables = Parser.GetAndSetVariablesFromTemplate(subject, item, null, null);
subject = Parser.SetValuesToContent(subject, subjectVariables, designerVariables);
body = Parser.SetValuesToContent(body, bodyVariables, designerVariables);
if (itemTemplate.VerifyFieldAccess("SendAsPlainText"))
{
sendAsPlainMode = Convert.ToBoolean(itemTemplate[new Guid("1BCADBD1-CC15-40A0-AAF7-6DE222412337")].ToString());
if (sendAsPlainMode)
body = body.ToPlainText();
}
MailMessage message = new MailMessage
{
Subject = subject,
Body = body,
IsBodyHtml = !sendAsPlainMode,
};
message.From = fromAddress;
// To mail
string[] arrTo = to.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
foreach (string t in arrTo)
message.To.Add(t);
// CC mail
if (!String.IsNullOrEmpty(cc))
{
string[] arrCC = cc.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
foreach (string c in arrCC)
message.CC.Add(c);
}
// Reply and body
if (!string.IsNullOrEmpty(reply))
{
message.ReplyTo = new MailAddress(reply);
}
else
{
if (currentUser != null && !string.IsNullOrEmpty(currentUser.Email))
message.ReplyTo = new MailAddress(currentUser.Email);
else
message.Body += "<br><br><i> System generated email, please do not reply to this message</i>";
}
foreach (Attachment a in attachments)
message.Attachments.Add(a);
// Send message
//string server = SPContext.Current.Site.WebApplication.OutboundMailServiceInstance.Server.Address;
//SmtpClient client = new SmtpClient(server);
SmtpClient client = getSmtpInformation();
client.Send(message);
}
示例3: SendEmailbytemplate
public static void SendEmailbytemplate(SPWeb web, SPListItem taskItem, SPListItem itemTemplate, string to, string cc, string variables, bool attachTaskLink)
{
string subject = string.Empty;
//string body = itemTemplate["Body"].ToString();
string body = EnsureAbsoluteUrl(web.Site, itemTemplate["Body"].ToString());
bool sendAsPlainMode = false;
if (itemTemplate.VerifyFieldAccess("SendAsPlainText")) //Fields.ContainsFieldWithStaticName("SendAsPlainText") && itemTemplate["SendAsPlainText"] != null)
{
sendAsPlainMode = Convert.ToBoolean(itemTemplate["SendAsPlainText"].ToString());
}
if (itemTemplate["Subject"] != null)
subject = itemTemplate["Subject"].ToString();
SendEmailbytemplate(web, taskItem, to, cc, variables, subject, body, sendAsPlainMode);
}