Esempio n. 1
0
        public Domain.Email.SMTPAccount GetSMTPAccount(string accountName)
        {
            var entity = new Models.CoreEntityModel().SMTPAccounts.Where(x => x.AccountName == accountName).FirstOrDefault();

            if (entity == null)
            {
                return(null);
            }

            var acct = new Domain.Email.SMTPAccount();

            acct.AuthenticationMode = ((int?)entity.AccountAuthMode) ?? 1;
            acct.DisplayName        = entity.AccountDisplayName;
            acct.FromAddress        = entity.AccountDefaultFromAddress;
            acct.ID             = entity.ID;
            acct.Name           = entity.AccountName;
            acct.Password       = entity.AccountPassword;
            acct.Port           = (int?)entity.AccountPort ?? 25;
            acct.ReplyToAddress = entity.AccountDefaultReplyAddress;
            acct.Server         = entity.AccountServer;
            acct.Username       = entity.AccountUsername;
            acct.UseSSL         = entity.AccountUseSSL ?? true;

            return(acct);
        }
Esempio n. 2
0
        public static void Send(Domain.Email.SMTPAccount account, string subject, string message, string recipient)
        {
            MailMessage mail   = new MailMessage(account.FromAddress, recipient);
            SmtpClient  client = new SmtpClient();

            client.Port                  = account.Port;
            client.DeliveryMethod        = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.EnableSsl             = account.UseSSL;
            client.Host                  = account.Server;
            client.Credentials           = new System.Net.NetworkCredential(account.Username, account.Password);

            mail.Subject = subject;
            mail.Body    = message;

            client.Send(mail);
        }
 public ActionResult RegisterProvider(int providerID, string registerAction, string providerNumber, string password, string email, bool sendEmail)
 {
     try
     {
         var model = new Models.ProviderPortal.RegisterVM
         {
             RegisterAction = registerAction,
             Email          = email,
             Password       = password,
             ProviderID     = providerID,
             ProviderNumber = providerNumber,
             SendEmail      = sendEmail
         };
         repository.RegisterProvider(model);
         if (sendEmail == true && !string.IsNullOrEmpty(email))
         {
             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 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 Provider Portal Account Created";
             string message = "An account has been created for you on the Applied Behavioral Provider Portal. You can log in to your new account at {0}\n\nUser Name: {1}\nPassword: {2}";
             message = String.Format(message, AppService.Current.Settings.ProviderPortalSite, providerNumber, password);
             DomainServices.Email.SMTP.Send(smtpAccount, subject, message, email);
         }
         return(Content("ok"));
     }
     catch (Exception e)
     {
         Dymeng.Framework.Exceptions.Handle(e, Global.GetWebInfo());
         return(Content("We're sorry, we ran into a problem registering this Provider.  Please contact your administrator or developer for details."));
     }
 }
Esempio n. 4
0
 public static void Send(Domain.Email.SMTPAccount account, string subject, string message, List <string> recipients, List <string> attachments)
 {
 }