public EnvelopeDO ConfigurePlainEmail(EmailDO email) { if (email == null) { throw new ArgumentNullException("email"); } return(ConfigureEnvelope(email, EnvelopeDO.MailHandler)); }
public EmailDO AddFromAddress(IUnitOfWork uow, EmailDO curEmail, string fromAddress) { var from = uow.EmailAddressRepository.GetOrCreateEmailAddress(fromAddress); curEmail.From = from; curEmail.FromID = from.Id; return(curEmail); }
public void Send(IUnitOfWork uow, EmailDO emailDO) { if (uow == null) { throw new ArgumentNullException("uow"); } uow.EnvelopeRepository.ConfigurePlainEmail(emailDO); uow.SaveChanges(); }
public void SendUserSettingsNotification(IUnitOfWork uow, Fr8AccountDO submittedDockyardAccountData) { EmailDO curEmail = new EmailDO(); curEmail.From = submittedDockyardAccountData.EmailAddress; curEmail.AddEmailRecipient(EmailParticipantType.To, submittedDockyardAccountData.EmailAddress); curEmail.Subject = "DockYardAccount Settings Notification"; //new Email(uow).SendTemplate(uow, "User_Settings_Notification", curEmail, null); //uow.EnvelopeRepository.ConfigureTemplatedEmail(curEmail, "User_Settings_Notification", null); }
public static EmailDO TestEmail1() { EmailDO curEmailDO = new EmailDO(); curEmailDO.Id = 1; curEmailDO.From = TestEmailAddress1(); curEmailDO.AddEmailRecipient(EmailParticipantType.To, TestEmailAddress2()); curEmailDO.Subject = "Main Subject"; curEmailDO.HTMLText = "This is the Body Text"; return(curEmailDO); }
public static EmailDO TestEmail3() { EmailDO curEmailDO = new EmailDO(); curEmailDO.Id = 3; curEmailDO.From = TestEmailAddress3(); curEmailDO.AddEmailRecipient(EmailParticipantType.To, TestEmailAddress3()); curEmailDO.Subject = "Main Subject"; curEmailDO.HTMLText = "This Email is intended to be used with KwasantIntegration account "; return(curEmailDO); }
public EmailDO AddSingleRecipient(IUnitOfWork uow, EmailDO curEmail, string toRecipient) { curEmail.Recipients = new List <RecipientDO>() { new RecipientDO() { EmailAddress = uow.EmailAddressRepository.GetOrCreateEmailAddress(toRecipient), EmailParticipantType = EmailParticipantType.To } }; return(curEmail); }
public void SendAlertEmail(string subject, string message = null) { using (IUnitOfWork uow = ObjectFactory.GetInstance <IUnitOfWork>()) { IConfigRepository configRepository = ObjectFactory.GetInstance <IConfigRepository>(); string fromAddress = configRepository.Get("EmailAddress_GeneralInfo"); EmailDO curEmail = new EmailDO(); curEmail = GenerateBasicMessage(uow, subject, message ?? subject, fromAddress, "*****@*****.**"); uow.EnvelopeRepository.ConfigurePlainEmail(curEmail); uow.SaveChanges(); } }
private EnvelopeDO ConfigureEnvelope(EmailDO email, string handler, string templateName = null, IDictionary <string, object> mergeData = null) { var envelope = new EnvelopeDO { TemplateName = templateName, Handler = handler }; if (!String.IsNullOrEmpty(templateName) && TemplateDescriptionMapping.ContainsKey(templateName)) { envelope.TemplateDescription = @"This email was generated by the template '" + TemplateDescriptionMapping[templateName] + "' and was sent to '" + String.Join(", ", email.Recipients.Select(r => r.EmailAddress.ToDisplayName())); } if (mergeData == null) { mergeData = new Dictionary <string, object>(); } var baseUrls = new List <String>(); const string baseUrlKey = "kwasantBaseURL"; if (mergeData.ContainsKey(baseUrlKey)) { var currentBaseURL = mergeData[baseUrlKey]; var baseUrlList = currentBaseURL as List <String>; if (baseUrlList == null) { baseUrls = new List <string> { currentBaseURL as String } } ; else { baseUrls = baseUrlList; } } mergeData[baseUrlKey] = baseUrls; foreach (var pair in mergeData) { envelope.MergeData.Add(pair); } email.EmailStatus = EmailState.Queued; ((IMailerDO)envelope).Email = email; envelope.EmailID = email.Id; Add(envelope); return(envelope); }
public void GenerateWelcomeEmail(string curUserId) { using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) { var curUser = uow.UserRepository.GetByKey(curUserId); EmailDO curEmail = new EmailDO(); curEmail.From = uow.EmailAddressRepository.GetOrCreateEmailAddress(_configRepository.Get("EmailAddress_GeneralInfo")); curEmail.AddEmailRecipient(EmailParticipantType.To, curUser.EmailAddress); curEmail.Subject = "Welcome to Kwasant"; //uow.EnvelopeRepository.ConfigureTemplatedEmail(curEmail, _configRepository.Get("welcome_to_kwasant_template"), null); //welcome to kwasant v2 template uow.SaveChanges(); } }
public EmailDO GenerateBasicMessage(IUnitOfWork uow, string subject, string message, string fromAddress, string toRecipient) { RegexUtilities.ValidateEmailAddress(_configRepository, toRecipient); EmailDO curEmail = new EmailDO { Subject = subject, PlainText = message, HTMLText = message }; curEmail = AddFromAddress(uow, curEmail, fromAddress); curEmail = AddSingleRecipient(uow, curEmail, toRecipient); return(curEmail); }
public EnvelopeDO ConfigureTemplatedEmail(EmailDO email, string templateName, IDictionary <string, object> mergeData = null) { if (mergeData == null) { mergeData = new Dictionary <string, object>(); } if (email == null) { throw new ArgumentNullException("email"); } if (string.IsNullOrEmpty(templateName)) { throw new ArgumentNullException("templateName", "Template name is null or empty."); } return(ConfigureEnvelope(email, EnvelopeDO.MailHandler, templateName, mergeData)); }
private async Task ReportAuthDeactivation(IUnitOfWork uow, PlanDO plan, InvalidTokenRuntimeException ex) { var activityTemplate = ex?.FailedActivityDTO.ActivityTemplate; string errorMessage = $"Activity {ex?.FailedActivityDTO.Label} was unable to authenticate with remote web-service."; errorMessage += $"Plan \"{plan.Name}\" which contains failed activity was deactivated."; _pusherNotifier.NotifyUser(new NotificationMessageDTO { NotificationType = NotificationType.GenericFailure, Subject = "Plan Failed", Message = errorMessage, Collapsed = false }, plan.Fr8AccountId); //Sending an Email var account = uow.UserRepository.GetQuery().FirstOrDefault(a => a.Id == plan.Fr8AccountId); try { var userEmail = account.UserName; var emailDO = new EmailDO(); IConfigRepository configRepository = ObjectFactory.GetInstance <IConfigRepository>(); string fromAddress = configRepository.Get("EmailAddress_GeneralInfo"); var emailAddressDO = uow.EmailAddressRepository.GetOrCreateEmailAddress(fromAddress); emailDO.From = emailAddressDO; emailDO.FromID = emailAddressDO.Id; emailDO.AddEmailRecipient(EmailParticipantType.To, uow.EmailAddressRepository.GetOrCreateEmailAddress(userEmail)); emailDO.Subject = "Your plan was deactivated due to authentication expiration"; string htmlText = $"Plan “{plan.Name}” was deactivated due to authentication problems. <br>If you would like to keep it active, please reauthenticate <a href='{Server.ServerUrl}dashboard/plans/{plan.Id}/builder?viewMode=plan'>here</a>"; emailDO.HTMLText = htmlText; uow.EnvelopeRepository.ConfigureTemplatedEmail(emailDO, "PlanDeactivated_Template"); uow.SaveChanges(); await ObjectFactory.GetInstance <IEmailPackager>().Send(new EnvelopeDO { Email = emailDO }); } catch { Logger.GetLogger().Error($"Couldn't send email to user {account.Id} to notify him about plan deactivation"); } }
public async Task ForgotPasswordAsync(string userEmail) { using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) { var userManager = new DockyardIdentityManager(uow); var user = await userManager.FindByEmailAsync(userEmail); if (user == null /* || !(await userManager.IsEmailConfirmedAsync(user.Id))*/) { // Don't reveal that the user does not exist or is not confirmed return; } var code = await userManager.GeneratePasswordResetTokenAsync(user.Id); code = HttpUtility.HtmlEncode(code); var callbackUrl = string.Format("{0}Account/ResetPassword?UserId={1}&code={2}", Server.ServerUrl, user.Id, code); var emailDO = new EmailDO(); IConfigRepository configRepository = ObjectFactory.GetInstance <IConfigRepository>(); string fromAddress = configRepository.Get("EmailAddress_GeneralInfo"); var emailAddressDO = uow.EmailAddressRepository.GetOrCreateEmailAddress(fromAddress); emailDO.From = emailAddressDO; emailDO.FromID = emailAddressDO.Id; emailDO.AddEmailRecipient(EmailParticipantType.To, uow.EmailAddressRepository.GetOrCreateEmailAddress(userEmail)); emailDO.Subject = "Password Recovery Request"; string htmlText = string.Format("Please reset your password by clicking this <a href='{0}'>link:</a> <br> <b>Note: </b> Reset password link will be expired after 24 hours.", callbackUrl); emailDO.HTMLText = htmlText; uow.EnvelopeRepository.ConfigureTemplatedEmail(emailDO, configRepository.Get("ForgotPassword_template"), new Dictionary <string, object>() { { "-callback_url-", callbackUrl } }); uow.SaveChanges(); await ObjectFactory.GetInstance <IEmailPackager>().Send(new EnvelopeDO { Email = emailDO }); } }
public Task SendAsync(IdentityMessage message) { using (var uow = ObjectFactory.GetInstance <IUnitOfWork>()) { String senderMailAddress = ObjectFactory.GetInstance <IConfigRepository>().Get("EmailAddress_GeneralInfo"); EmailDO emailDO = new EmailDO(); emailDO.AddEmailRecipient(EmailParticipantType.To, Email.GenerateEmailAddress(uow, new MailAddress(message.Destination))); emailDO.From = Email.GenerateEmailAddress(uow, new MailAddress(senderMailAddress)); emailDO.Subject = message.Subject; emailDO.HTMLText = message.Body; //uow.EnvelopeRepository.ConfigurePlainEmail(emailDO); uow.SaveChanges(); return(Task.FromResult(0)); } }
public string PackResponseGetEmail(EmailDO curEmailDO) { return(jsonSerializer.Serialize(curEmailDO)); }