protected void btnSbt_Click(object sender, EventArgs e)
        {
            Panel1.Visible = false;
            GoodEatsFarmDataContext db = new GoodEatsFarmDataContext();

            if (TextBox3.Text != null && TextBox3.Text != String.Empty)
            {
                string phoneTxt = TextBox3.Text;
                string phone    = (Regex.Replace(phoneTxt, "[^0-9]", ""));
                db.uspConnectionInsert(TextBox1.Text, TextBox2.Text, phone);
            }
            else
            {
                db.uspConnectionInsert(TextBox1.Text, TextBox2.Text, null);
            }


            Panel2.Visible = true;
        }
Esempio n. 2
0
        protected void SendMail()
        {
            // Gmail Address from where you send the mail
            var fromAddress = "*****@*****.**";
            // any address where the email will be sending
            var toAddress = "*****@*****.**";
            //Password of your gmail address
            const string fromPassword = "******";
            // Passing the values and make a email formate to display
            string subject = YourSubject.Text.ToString();
            string body    = "From: " + YourName.Text + "\n";

            body += "Email: " + YourEmail.Text + "\n";
            body += "Subject: " + YourSubject.Text + "\n";
            body += "Question: \n" + Comments.Text + "\n";
            // smtp settings
            var smtp = new System.Net.Mail.SmtpClient();

            {
                smtp.Host = "smtp-mail.outlook.com";
                smtp.Port = 587;
                //IMap-MailDefinition.outlook.com=993
                smtp.EnableSsl      = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials    = new NetworkCredential(fromAddress, fromPassword);
                smtp.Timeout        = 20000;
            }
            // Passing values to smtp object
            smtp.Send(fromAddress, toAddress, subject, body);

            if (chkbxOptIntoMail.Checked)
            {
                GoodEatsFarmDataContext db = new GoodEatsFarmDataContext();
                db.uspConnectionInsert(YourName.Text, YourEmail.Text, null);
            }
        }