public SendMultipleEmailAsync ( |
||
smtpOptions | ||
toCsv | string | |
from | string | |
subject | string | |
plainTextMessage | string | |
htmlMessage | string | |
return | System.Threading.Tasks.Task |
public async Task AccountPendingApprovalAdminNotification( ISiteSettings siteSettings, ISiteUser user) { if(siteSettings.AccountApprovalEmailCsv.Length == 0) { return; } SmtpOptions smtpOptions = GetSmptOptions(siteSettings); if (smtpOptions == null) { var logMessage = $"failed to send new account notifications to admins because smtp settings are not populated for site {siteSettings.SiteName}"; log.LogError(logMessage); return; } string subject = "New Account Pending Approval"; string plainTextTemplate = templateService.GetPlainTextTemplate(MessagePurpose.ConfirmAccount, CultureInfo.CurrentUICulture.Name); //string plainTextMessage = string.Format(plainTextTemplate, confirmationUrl); //string plainTextMessage = "U" var message = $"A new user just registered at {siteSettings.SiteName} with email address {user.Email}"; //string htmlTemplate = templateService.GetHtmlTemplate(MessagePurpose.ConfirmAccount, CultureInfo.CurrentUICulture.Name); //string htmlMessage = string.Format(htmlTemplate, confirmationUrl); EmailSender sender = new EmailSender(); try { await sender.SendMultipleEmailAsync( smtpOptions, siteSettings.AccountApprovalEmailCsv, siteSettings.DefaultEmailFromAddress, subject, message, string.Empty).ConfigureAwait(false); } catch (Exception ex) { log.LogError("error sending email verification email", ex); } }
public async Task AccountPendingApprovalAdminNotification( ISiteContext siteSettings, ISiteUser user) { if (siteSettings.AccountApprovalEmailCsv.Length == 0) { return; } SmtpOptions smtpOptions = GetSmptOptions(siteSettings); if (smtpOptions == null) { var logMessage = $"failed to send new account notifications to admins because smtp settings are not populated for site {siteSettings.SiteName}"; log.LogError(logMessage); return; } string subject = sr["New Account Pending Approval"]; EmailSender sender = new EmailSender(); try { var plainTextMessage = await viewRenderer.RenderViewAsString<ISiteUser>("EmailTemplates/AccountPendingApprovalAdminNotificationTextEmail", user).ConfigureAwait(false); var htmlMessage = await viewRenderer.RenderViewAsString<ISiteUser>("EmailTemplates/AccountPendingApprovalAdminNotificationHtmlEmail", user).ConfigureAwait(false); await sender.SendMultipleEmailAsync( smtpOptions, siteSettings.AccountApprovalEmailCsv, smtpOptions.DefaultEmailFromAddress, subject, plainTextMessage, htmlMessage).ConfigureAwait(false); } catch (Exception ex) { log.LogError("error sending email verification email", ex); } }