本文整理汇总了C#中ErrorLog.WriteLogMessage方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorLog.WriteLogMessage方法的具体用法?C# ErrorLog.WriteLogMessage怎么用?C# ErrorLog.WriteLogMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorLog
的用法示例。
在下文中一共展示了ErrorLog.WriteLogMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMail
/// <summary>
/// 메일발송 - DataPack
/// </summary>
/// <param name="lo_dp"></param>
/// <returns></returns>
public string SendMail(DataPack lo_dp)
{
try
{
this.from = String.IsNullOrEmpty(lo_dp["From"].ToString()) ? "" : lo_dp["From"].ToString();
this.to = String.IsNullOrEmpty(lo_dp["To"].ToString()) ? "" : lo_dp["To"].ToString();
this.subject = String.IsNullOrEmpty(lo_dp["Subject"].ToString()) ? "NO TITLE" : lo_dp["Subject"].ToString();
this.body = String.IsNullOrEmpty(lo_dp["Body"].ToString()) ? "NO CONTENTS" : lo_dp["Body"].ToString();
this.isBodyHtml = String.IsNullOrEmpty(lo_dp["IsBodyHtml"].ToString()) ? false : Convert.ToBoolean(lo_dp["IsBodyHtml"].ToString());
MailMessage msg = new MailMessage();
msg.From = new MailAddress(from.Trim());
msg.To.Add(new MailAddress(to.Trim()));
msg.Subject = subject.Trim();
msg.Body = body.Trim();
msg.BodyEncoding = BodyEncoding;
msg.IsBodyHtml = isBodyHtml;
SmtpClient sc = new SmtpClient();
sc.Host = hostName;
sc.Send(msg);
//로깅
if (WebConfig.SMFramework["Mail.Logging"].ToUpper() == "TRUE")
{
_mailLog = new ErrorLog("Mail", "SMFramework", WebConfig.SMFramework["Mail.LogFile"]);
DataPack lo_dp_header = new DataPack();
string[] keys = msg.Headers.AllKeys;
foreach (string s in keys)
{
lo_dp_header.AddProperty(s, typeof(string), msg.Headers[s]);
}
lo_dp_header.AddProperty("host", typeof(string), hostName);
lo_dp_header.AddProperty("subject", typeof(string), subject);
lo_dp_header.AddProperty("isBodyHtml", typeof(string), isBodyHtml.ToString());
lo_dp_header.AddProperty("bodyEncoding", typeof(string), msg.BodyEncoding.BodyName);
string ls_msg = Utility.ConversionUtil.ExtractDataInfo("--- SendMail Result ---", lo_dp_header);
ls_msg = ls_msg.Replace("<br>", "\r\n");
_mailLog.WriteLogMessage(ls_msg, System.Diagnostics.EventLogEntryType.Information);
}
}
catch (Exception e)
{
_mailLog.WriteLogMessage(e.Message, System.Diagnostics.EventLogEntryType.Error);
return e.Message;
}
return "OK";
}