コード例 #1
0
        protected void btEnviar_Click(object sender, EventArgs e)
        {
            bool b = false;

            try
            {
                using (var client = new WebClient())
                    using (client.OpenRead("http://google.com/generate_204"))
                        b = true;
            }
            catch
            {
                b = false;
            }
            if (b == true)
            {
                MailMessage mailMessage = new MailMessage();
                mailMessage.From = new MailAddress("*****@*****.**");
                mailMessage.To.Add(lbEmail.Text);
                mailMessage.Subject    = tbxAssunto.Text;
                mailMessage.Body       = "<h3>G.E.T</h3><br/>" + tbxMensagem.Text;
                mailMessage.IsBodyHtml = true;

                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.EnableSsl             = true;
                smtpClient.DeliveryMethod        = SmtpDeliveryMethod.Network;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "teste123456");
                smtpClient.Send(mailMessage);
                String str = "<script>alertify.success('Email enviado com sucesso!');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str, false);
                divContactar.Visible = false;
                tbxMensagem.Text     = "";
                tbxAssunto.Text      = "";
            }
            else
            {
                MPE_User.Hide();
                divContactar.Visible = false;
                btContactar.Enabled  = false;
                tbxMensagem.Text     = "";
                tbxAssunto.Text      = "";
                String str1 = "<script>alertify.error('Sem ligação! Email não enviado.');</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Script", str1, false);
            }
        }
コード例 #2
0
 protected void btFecharUser_Click(object sender, EventArgs e)
 {
     MPE_User.Hide();
 }