本文整理汇总了C#中Email.send_html方法的典型用法代码示例。如果您正苦于以下问题:C# Email.send_html方法的具体用法?C# Email.send_html怎么用?C# Email.send_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email.send_html方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendContactMessage
public bool SendContactMessage(string name , string email, string phone, string location, string message)
{
string path = HttpContext.Current.Server.MapPath("~" + ConfigurationManager.AppSettings["savedmessagepath"] +
String.Format("{0:s}", DateTime.Now).Replace('T', '_').Replace(':', '-') + ".txt");
try
{
StringBuilder sbBody = new StringBuilder();
sbBody.Append(" Dear Admin," + Environment.NewLine);
sbBody.Append(string.Format("A user with the following name {0}, number {1} and location {2}." + Environment.NewLine, name, phone, location));
sbBody.Append("Has sent the following message." + Environment.NewLine);
sbBody.Append("----------------------------------------------------------------" + Environment.NewLine + message + Environment.NewLine);
//persist message in file
using (TextWriter writer = File.CreateText(path))
{
writer.WriteLine(sbBody.ToString());
}
Email mail = new Email(EmailConstants.SMTPServer, EmailConstants.AdminEmail, EmailConstants.AdminPass);
return mail.send_html(EmailConstants.AdminEmail, EmailConstants.AdminName, email, name, "[Global Service Security] - New Enquriy", sbBody.ToString());
}
catch(Exception ex) {
using (TextWriter writer = File.CreateText(path))
{
writer.WriteLine("Email sent failed." + ex.Message);
}
return false;
}
}