Example #1
0
        public static void SendEmailWithBody(String body, string toEmailAddress)
        {
            SimpleAES crypt = new SimpleAES();
            string fromaddress = crypt.DecryptString(ConfigurationManager.AppSettings["UserName"]);
            string password = crypt.DecryptString(ConfigurationManager.AppSettings["Password"]);
            if (fromaddress == "" || password == "")
            {
                MessageBox.Show("No HKT email credentials have been provided.");
                return;
            }

            string toaddress = toEmailAddress;
            MailMessage message = new MailMessage(fromaddress, toaddress);
            message.Subject = "Your e-Receipt From HKT Custom Clothiers";
            message.Body = body;
            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential(fromaddress, password);
            try
            {
                client.Send(message);
                MessageBox.Show("Done! E-mail was queued.");
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error sending your email. Please contact Jay with this message: " + ex.Message);
            }
        }
Example #2
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            SimpleAES crypt = new SimpleAES();

            String username = crypt.EncryptToString(UserNametextBox.Text);
            String password = crypt.EncryptToString(PasswordTextBox.Text);

            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            config.AppSettings.Settings["UserName"].Value = username;
            config.AppSettings.Settings["Password"].Value = password;
            config.Save(ConfigurationSaveMode.Modified);

            ConfigurationManager.RefreshSection("appSettings");

            this.Close();
        }