/// <summary> /// Send notification email to specific users on process of title job /// </summary> /// <param name="notificationTYpe">Type of notification o send</param> /// <param name="jobStatus">Success or Failure</param> public void SendJobNotification(JobNotificationType notificationTYpe, JobStatus jobStatus) { dlxMailMessage dlxMessage = DeluxeOM.Services.Common.Mapper.GetMailMessageModel(_repository.GetNotificationMessage(notificationTYpe)); //bool isSuccess = jobStatus.Success; //int jobId = jobStatus.JobId ; if (!App.Config.EnableEmailNotifications || !dlxMessage.IsActive) { return; } if (string.IsNullOrEmpty(dlxMessage.To)) { return; } string recordImporetd = jobStatus.Success ? jobStatus.NoOfRecordsImported.ToString() : string.Empty; string body = jobStatus.Success ? dlxMessage.SuccessBody : dlxMessage.FailureBody; body = string.Format(body, jobStatus.FileName, recordImporetd, DateTime.Now.ToString()); dlxMessage.SuccessBody = body; string subject = jobStatus.Success ? dlxMessage.SuccessSubject : dlxMessage.FailureSubject; dlxMessage.SuccessSubject = subject; SendEmail(dlxMessage); }
/// <summary> /// Send mail /// </summary> /// <param name="dlxMessage">Mail body(include sender reciever)</param> public void SendEmail(dlxMailMessage dlxMessage) { if (!App.Config.EnableEmailNotifications) { return; } var emailConfig = App.Config.SmtpMail; MailMessage message = new MailMessage() { From = new MailAddress(dlxMessage.From), Body = dlxMessage.SuccessBody, Subject = dlxMessage.SuccessSubject }; dlxMessage.To.Split(',').ToList().ForEach(x => message.To.Add(x)); message.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Host = emailConfig.Server; client.Port = int.Parse(emailConfig.Port); client.UseDefaultCredentials = false; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = emailConfig.EnableSSL; client.Credentials = new NetworkCredential(emailConfig.UserName, emailConfig.Password); client.Send(message); }
private bool CreateForgotPasswordNotification(PasswordReset model) { bool retVal = true; string uiBaseUrl = App.Config.UIBaseUrl; string action = App.Config.RecoverPasswordAction; int expireMins = App.Config.ForgotPasswordInterval; string txtLink = string.Format(action, model.Token); string adminEmail = App.Config.AdminEmailAddress; //string emailBody = string.Format("Hi, <br> You recently requested to reset your password to your DeluxeOrderManagement account. Click the button below to reset it. <br> <a href={0}. <br>This link is only valid for {1} next minutes>", txtLink, expireMins.ToString()); string emailBody = string.Format("Hi, <html><body><br> You recently requested to reset your password to your DeluxeOrderManagement account. Click the button below to reset it. <br> <a href={0} <br>This link is only valid for {1} next minutes</body></html>", uiBaseUrl + txtLink, expireMins.ToString()); INotificationService nfnService = new NotificationService(); dlxMailMessage message = new dlxMailMessage() { From = adminEmail, SuccessBody = emailBody, SuccessSubject = "Forgot Password", To = model.Email }; nfnService.SendEmail(message); /* * htp://om.domain.com/resetpassword/tokenguid * bool retVal = false ; * * string uiBaseUrl = Config.UIBaseUrl; // https://om.deluxe.com * string controller = Config.RecoverPasswordController"; * string action = Config.RecoverPasswordAction"; * int expireMins = Config.ForgotPasswordInterval"; * * string adminEmail = Config.AdminEmailAddress; * string txtLink = string.Format(Resources.Account.ResetPasswordLinkText, uiBaseUrl, controller, action, HttpUtility.UrlEncode(model.Token)); * string htmlLink = string.Format(Resources.Account.ResetPasswordLinkHtml, uiBaseUrl, controller, action, HttpUtility.UrlEncode(model.Token)); * string txtBody = string.Format(Resources.Account.ResetPasswordBodyText, model.FirstName, model.LastName, adminEmail, txtLink, expireMins); * string htmlBody = string.Format(Resources.Account.ResetPasswordBodyHtml, model.FirstName, model.LastName, adminEmail, htmlLink, expireMins); * * NotifyItem mail = new NotifyItem(); * mail.NotifyType = Core.NotifyType.SmtpMail; * mail.ContentType = Core.NotifyContentType.PasswordChange; * mail.NotifyDatetime = DateTime.Now; * mail.Address = model.Email; * mail.Subject = Resources.Account.ForgotPasswordSubject; * mail.BodyText = txtBody; * mail.BodyHtml = htmlBody; * mail.IsBodyHtml = true; * * if (_notifyDB.Add(mail) == 1) * retVal = true; */ return(retVal); }
public void VerifySmtpEmail() { INotificationService ntfn = new NotificationService(); dlxMailMessage dlxMessage = new dlxMailMessage() { From = "*****@*****.**", To = "*****@*****.**", SuccessSubject = "Test email", SuccessBody = "test body" }; ntfn.SendEmail(dlxMessage); Assert.IsTrue(true); }
/// <summary> /// Send notification email to specific users on import of announcement /// </summary> /// <param name="jobStatus">Success or Failure</param> public void SendAnnouncementNewTitlesNotification(JobStatus jobStatus) { dlxMailMessage dlxMessage = DeluxeOM.Services.Common.Mapper.GetMailMessageModel(_repository.GetNotificationMessage(JobNotificationType.NewTitlesNotification)); if (!App.Config.EnableEmailNotifications || !dlxMessage.IsActive) { return; } if (string.IsNullOrEmpty(dlxMessage.To)) { return; } string body = dlxMessage.SuccessBody; body = string.Format(body, jobStatus.FileName, getNewTitlesHTML(jobStatus.JobId), DateTime.Now.ToString()); dlxMessage.SuccessBody = body; SendEmail(dlxMessage); #region Commented //var emailConfig = App.Config.SmtpMail; //MailMessage message = new MailMessage() //{ // From = new MailAddress(dlxMessage.From), // Subject = subject //}; //if (notificationTYpe == JobNotificationType.LoadAnnouncementNotification) // message.Body = string.Format("{0}<br/><br/>{1}", body, getAnnouncementJobBody(jobStatus.JobId)); //else // message.Body = body; //dlxMessage.To.Split(',').ToList().ForEach(x => message.To.Add(x)); //message.IsBodyHtml = true; //SmtpClient client = new SmtpClient(); //client.Host = emailConfig.Server; //client.Port = int.Parse(emailConfig.Port); //client.UseDefaultCredentials = false; //client.DeliveryMethod = SmtpDeliveryMethod.Network; //client.EnableSsl = emailConfig.EnableSSL; //client.Credentials = new NetworkCredential(emailConfig.UserName, emailConfig.Password); //client.Send(message); #endregion }