本文整理汇总了C#中IEmailService.SendAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IEmailService.SendAsync方法的具体用法?C# IEmailService.SendAsync怎么用?C# IEmailService.SendAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEmailService
的用法示例。
在下文中一共展示了IEmailService.SendAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessPrivateMeetingNotifications
public static void ProcessPrivateMeetingNotifications(ApplicationUser currentUser, List<Meeting> meetingsBooked,
IEmailService emailService,
ApplicationUserManager userManager, ApplicationRoleManager roleManager)
{
var studentConfirmationEmailMessage = Compose_Private_Booking_Email(currentUser, meetingsBooked, userManager,
true);
try
{
emailService.SendAsync(studentConfirmationEmailMessage);
Log4NetHelper.Log("Send Message To Student: " + studentConfirmationEmailMessage.To, LogLevel.INFO,
"ProcessPrivateMeetingNotifications", meetingsBooked.First().Id,
"Tester", null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.ERROR, "Meetings",
meetingsBooked.First().Id,
"Tester", ex);
}
var instructorId = meetingsBooked.FirstOrDefault()?.InstructorId;
var instructor = userManager.FindById(instructorId);
//Roger todo only first instructor will get notification message;
var instructorConfirmationEmailMessage = Compose_Private_Booking_Email(instructor, meetingsBooked,
userManager, false);
if (instructorConfirmationEmailMessage != null)
{
try
{
emailService.SendAsync(instructorConfirmationEmailMessage);
Log4NetHelper.Log("Send Message To Instructor: " + instructorConfirmationEmailMessage.To,
LogLevel.INFO, "ProcessPrivateMeetingNotifications", meetingsBooked.First().Id,
"Tester", null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.INFO, "Meetings",
meetingsBooked.First().Id,
"Tester", ex);
}
}
}
示例2: Send_Private_Booking_Invitation
public static void Send_Private_Booking_Invitation(Meeting meetingBooked, IEmailService emailService,
ApplicationUserManager userManager)
{
var instructor = userManager.FindById(meetingBooked.InstructorId);
var student = userManager.FindById(meetingBooked.StudentId);
var subjectLine = "Meeting: " + meetingBooked.Title + " - " + StarterTimeText(meetingBooked);
var bodyText = GenerateInvitationText(meetingBooked, "", student, instructor);
var confirmationEmailMessage = BuildEmailMessage(student, subjectLine, bodyText);
try
{
emailService.SendAsync(confirmationEmailMessage);
Log4NetHelper.Log("Send Message To Student: " + confirmationEmailMessage.To, LogLevel.INFO,
"ProcessPrivateMeetingNotifications", meetingBooked.Id,
instructor.Email, null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.ERROR, "Meetings", meetingBooked.Id,
instructor.Email, ex);
}
}
示例3: SendMeetingNotifications
public static void SendMeetingNotifications(Course course, Meeting meetingBooked, IEmailService emailService,
ApplicationDbContext context, ApplicationUser instructor)
{
var enrollments = context.Enrollments.Include("ApplicationUser").Where(e => e.CourseId == course.Id);
foreach (var enrollment in enrollments)
{
try
{
var bodyText = GenerateBodyText(meetingBooked, course.Title, enrollment.ApplicationUser, instructor);
var confirmationEmailMessage = BuildEmailMessage(enrollment.ApplicationUser, meetingBooked.Title,
bodyText);
emailService.SendAsync(confirmationEmailMessage);
var logMessage = "Notice of meeting for " + course.Title + " - " + meetingBooked.Title + " sent to " +
enrollment.ApplicationUser.FullName;
Log4NetHelper.Log("logMessage", LogLevel.INFO, "MeetingService", 133,
meetingBooked.Instructor.FullName, null);
}
catch (Exception ex)
{
Log4NetHelper.Log("Send Student Message Failed - ", LogLevel.ERROR, "ManageMeetings", 342, "Tester",
ex);
}
}
}