本文整理汇总了C#中Email.SendError方法的典型用法代码示例。如果您正苦于以下问题:C# Email.SendError方法的具体用法?C# Email.SendError怎么用?C# Email.SendError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email.SendError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Logger logger = LogManager.GetCurrentClassLogger();
var email = new Email();
try
{
IWindsorContainer container = new WindsorContainer();
ComponentRegistrar.AddComponentsTo(container);
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
NHibernateInitializer.Init();
DateTime weekEndingDate;
if (args.Length > 0)
{
if (!DateTime.TryParse(args[0], out weekEndingDate))
{
var msg = string.Format("Invalid command line argument. args[0] = {0}", args[0]);
logger.Error(msg);
throw new Exception(msg);
}
}
else
{
weekEndingDate = Dates.GetPreviousSaturday(DateTime.Today);
}
var audit = container.Resolve<Audit>();
audit.RunAudit(weekEndingDate);
}
catch (Exception ex)
{
logger.Error(ex.Message);
logger.Error(ex.StackTrace);
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
var subject = "Error in " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
var body = string.Format("The following exception was thrown in {0}\n\nMessage:\n{1} \n\nStack:\n{2}", System.Reflection.Assembly.GetExecutingAssembly().FullName, ex.Message, ex.StackTrace);
logger.Error(body);
#if(DEBUG)
Console.WriteLine(body);
#else
email.SendError(subject, body);
#endif
}
}