本文整理汇总了C#中Email.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# Email.Authenticate方法的具体用法?C# Email.Authenticate怎么用?C# Email.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Email
的用法示例。
在下文中一共展示了Email.Authenticate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendEmails
//.........这里部分代码省略.........
}
}
}
else if (nextUpdateRequest != null)
{
// send email if sent date is not null and later than x days after sent
if (nextUpdateRequest.LastSentDate.HasBeenSet() == false)
{
shouldSendEmail = true;
}
else if (nextUpdateRequest.LastSentDate.TimeUntilNow().Minutes > importTask.ImportTaskConfiguration.DaysBetweenEmails)
{
shouldSendEmail = true;
}
else if (nextUpdateRequest.LastSentDate.TimeUntilNow().Minutes > importTask.ImportTaskConfiguration.DaysUntilEmailReminder)
{
isReminder = true;
shouldSendEmail = true;
}
}
if (shouldSendEmail)
{
// create new update request
employee.Reload();
UpdateRequest nextRequest = importTask.UpdateRequestForEmployeeWithStep(lastStepCompleted + 1, employee);
if (nextRequest != null)
{
ImportTaskEmail email = importTask.ImportTaskConfiguration.ImportTaskEmails.ToList<ImportTaskEmail>().Where(x => x.Step == nextStep).FirstOrDefault();
string emailLink = Utilities.Domain() + UrlManager.EmployeeEditWithRequestUpdateOid(nextRequest.Oid);
string name = String.IsNullOrEmpty(employee.FullName()) ? "there" : employee.FullName();
string subject = String.IsNullOrEmpty(email.Subject) == false ? email.Subject : "Update your data";
subject = subject.Replace(EmployeeFullNamePlaceHolder, name);
if (isReminder)
{
subject += " (Reminder)";
}
string emailText = email.EmailText;
string toEmail = employee.EmailAddress;
string body = emailText + "<br/>" + emailLink;
body = body.Replace(EmployeeFullNamePlaceHolder, employee.FullName());
Email mail = new Email()
{
Subject = subject,
ToEmail = toEmail,
Body = body
};
ValidationResult validation = new EmailValidator().Validate(mail);
if (validation.IsValid == true)
{
if (nextRequest.OriginalSentDate.HasBeenSet() == false)
{
nextRequest.OriginalSentDate = DateTime.Now;
}
nextRequest.LastSentDate = DateTime.Now;
nextRequest.TimesSent++;
nextRequest.Save();
Debug.WriteLine("Sending email to: " + toEmail + " with body: " + body);
if (toEmail == "[email protected]")
{
mail.Authenticate("[email protected]", "yfwlmyeevmvbdbjq").Send();
}
emailsSent++;
}
else
{
Debug.WriteLine("Error sending email to: " + toEmail + " with error: " + String.Join(",", validation.Errors));
}
}
else
{
Debug.WriteLine("Next request was null - meaning employee is done.");
}
}
}
}
}
}
}
session.Disconnect();
session.Dispose();
Debug.Write(emailsSent + " would be sent /n");
}
catch (Exception e)
{
Debug.Write("background email task threw ex" + e);
}
}