Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Net;
- using System.Net.Mail;
- using MySql.Data.MySqlClient;
- public partial class lembrarsenha : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string conexao = "Server=LocalHost;Database=StoneHenge;Uid=root;Pwd='';Connect Timeout=30";
- MySqlConnection conn = new MySqlConnection(conexao);
- string comando = "select * from usuario where email='" + email.Text + "'";
- MySqlCommand cmd = new MySqlCommand(comando, conn);
- conn.Open();
- MySqlDataReader dr = cmd.ExecuteReader();
- dr.Read();
- if (dr.HasRows)
- {
- SmtpClient smtp = new SmtpClient();
- MailMessage mss = new MailMessage();
- mss.From =new MailAddress("seuemail@dominio.com.br");
- mss.To.Add(email.Text);
- mss.Subject = "Testando envio de email pelo C#";
- string corpo = "Este é um teste de envio por uma app em asp.net e c#";
- corpo += "\n Usuario "+dr["nome"];
- corpo += "\n senha " + dr["senha"];
- mss.Body = corpo;
- smtp.Credentials = new NetworkCredential(txtnome.Text, txtsenha.Text);
- smtp.Port = 25;
- smtp.EnableSsl = true;
- smtp.Host = "smtp.live.com"; // smtp.gmail.com
- smtp.Send(mss);
- }
- else
- {
- mensagem.Text = "usuario não encontrado!";
- //mensagem.Text = "rows "+dr.RecordsAffected.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement