internal void ReportHours(int hoursID, string comment) { var reportedHours = _context.Hours.Find(hoursID); reportedHours.ParentReported = true; _context.SaveChanges(); var smtpInfo = _contextOld.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault(); if (smtpInfo == null) { throw new ArgumentNullException("Primary SMTP Account info has not been configured."); } var smtpAccount = new AABC.Domain.Email.SMTPAccount() { Username = smtpInfo.AccountUsername, Password = smtpInfo.AccountPassword, Server = smtpInfo.AccountServer, Port = smtpInfo.AccountPort.Value, UseSSL = smtpInfo.AccountUseSSL.Value, AuthenticationMode = smtpInfo.AccountAuthMode.Value, FromAddress = smtpInfo.AccountDefaultFromAddress, ReplyToAddress = smtpInfo.AccountDefaultReplyAddress }; string subjectText = "Hours Reported - " + reportedHours.Case.Patient.CommonName; string messageFormat = @"Hours Reported Patient: {0} {1} {2} {3} - {4} Provider: {5} {6}, {7} Comments: {8}"; string messageText = String.Format(messageFormat, reportedHours.Case.Patient.CommonName, reportedHours.Case.Patient.Email, reportedHours.Date.ToString("D"), reportedHours.StartTime.ToString("hh\\:mm"), reportedHours.EndTime.ToString("hh\\:mm"), reportedHours.Provider.FirstName, reportedHours.Provider.LastName, reportedHours.Service.Name, comment); string mailToAddress = System.Configuration.ConfigurationManager.AppSettings["ReportHoursMailtoAddress"]; AABC.DomainServices.Email.SMTP.Send(smtpAccount, subjectText, messageText, mailToAddress); }
static void testEmailSmtp() { AABC.Data.Models.CoreEntityModel _context; AABC.Domain.Email.SMTPAccount _smtpAccount; string _errorEmail; _context = new AABC.Data.Models.CoreEntityModel(); _errorEmail = ConfigurationManager.AppSettings["ErrorEmail"]; var smtpInfo = _context.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault(); if (smtpInfo == null) { Console.WriteLine("FAIL: (smtp) Unable to load Primary smtp account"); return; } _smtpAccount = new AABC.Domain.Email.SMTPAccount() { Username = smtpInfo.AccountUsername, Password = smtpInfo.AccountPassword, Server = smtpInfo.AccountServer, Port = smtpInfo.AccountPort.Value, UseSSL = smtpInfo.AccountUseSSL.Value, AuthenticationMode = smtpInfo.AccountAuthMode.Value, FromAddress = smtpInfo.AccountDefaultFromAddress, ReplyToAddress = smtpInfo.AccountDefaultReplyAddress }; try { AABC.DomainServices.Email.SMTP.Send( _smtpAccount, "Test Message", "This is a test message from auto referrals entry - please disregard.", _errorEmail); } catch (Exception e) { Console.WriteLine("FAIL: (smtp)"); Console.WriteLine(e.ToString()); return; } Console.WriteLine("SUCCESS (smtp)"); }
internal string ResetPassword(int loginID) { var membership = _context.PatientPortalLogins.Find(loginID).WebMembershipDetail; string pass = PatientPortalExtendedServices.GeneratePassword(); membership.Password = pass; _context.SaveChanges(); var smtpInfo = AppService.Current.DataContext.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault(); if (smtpInfo == null) { throw new ArgumentNullException("Primary SMTP Account info has not been configured."); } var smtpAccount = new AABC.Domain.Email.SMTPAccount() { Username = smtpInfo.AccountUsername, Password = smtpInfo.AccountPassword, Server = smtpInfo.AccountServer, Port = smtpInfo.AccountPort.Value, UseSSL = smtpInfo.AccountUseSSL.Value, AuthenticationMode = smtpInfo.AccountAuthMode.Value, FromAddress = smtpInfo.AccountDefaultFromAddress, ReplyToAddress = smtpInfo.AccountDefaultReplyAddress }; string subject = "Applied Behavioral Parent Portal Account Password Reset"; string message = "The password for your account on the Applied Behavioral Parent Portal has been reset. You can log in to your account at {0}\n\nUserName: {1}\nPassword: {2}"; message = String.Format(message, AppService.Current.Settings.PatientPortalSite, membership.User.Email, pass); AABC.DomainServices.Email.SMTP.Send(smtpAccount, subject, message, membership.User.Email); return(pass); }
internal string AddLogin(string email, string firstName, string lastName, bool active) { if (_context.PatientPortalLogins.Where(x => x.Email == email).Count() > 0) { return(null); } // EF6 add login is giving me errors about inserting IDs and I've spent enough time // trying to troubleshoot... will resort to manual creation here string password = PatientPortalExtendedServices.CreateLogin(email, firstName, lastName, active); var smtpInfo = AppService.Current.DataContext.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault(); if (smtpInfo == null) { throw new ArgumentNullException("Primary SMTP Account info has not been configured."); } var smtpAccount = new AABC.Domain.Email.SMTPAccount() { Username = smtpInfo.AccountUsername, Password = smtpInfo.AccountPassword, Server = smtpInfo.AccountServer, Port = smtpInfo.AccountPort.Value, UseSSL = smtpInfo.AccountUseSSL.Value, AuthenticationMode = smtpInfo.AccountAuthMode.Value, FromAddress = smtpInfo.AccountDefaultFromAddress, ReplyToAddress = smtpInfo.AccountDefaultReplyAddress }; string subject = "Applied Behavioral Parent Portal Account Created"; string message = "An account has been created for you on the Applied Behavioral Parent Portal. You can log in to your new account at {0}\n\nUserName: {1}\nPassword: {2}"; message = String.Format(message, AppService.Current.Settings.PatientPortalSite, email, password); AABC.DomainServices.Email.SMTP.Send(smtpAccount, subject, message, email); return(password); }
public ReferralsFromEmail() { _context = new AABC.Data.Models.CoreEntityModel(); _logger = new Logger(); _popServer = ConfigurationManager.AppSettings["PopServer"]; _popPort = int.Parse(ConfigurationManager.AppSettings["PopPort"]); _popSSL = bool.Parse(ConfigurationManager.AppSettings["PopSSL"]); _popUser = ConfigurationManager.AppSettings["PopUser"]; _popPassword = ConfigurationManager.AppSettings["PopPassword"]; _seedMode = bool.Parse(ConfigurationManager.AppSettings["SeedMode"]); var smtpInfo = _context.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault(); if (smtpInfo == null) { throw new ArgumentNullException("Primary SMTP Account info has not been configured."); } _smtpAccount = new AABC.Domain.Email.SMTPAccount() { Username = smtpInfo.AccountUsername, Password = smtpInfo.AccountPassword, Server = smtpInfo.AccountServer, Port = smtpInfo.AccountPort.Value, UseSSL = smtpInfo.AccountUseSSL.Value, AuthenticationMode = smtpInfo.AccountAuthMode.Value, FromAddress = smtpInfo.AccountDefaultFromAddress, ReplyToAddress = smtpInfo.AccountDefaultReplyAddress }; _validationEmail = ConfigurationManager.AppSettings["ValidationEmail"]; _errorEmail = ConfigurationManager.AppSettings["ErrorEmail"]; }