protected void TextBox7_TextChanged(object sender, EventArgs e) { string gMailAccount = "[[[Email Removed]]]"; string password = "[[[Password Removed]]]"; string yes; TextBox21.Visible = true; Label26.Visible = true; Random val = new Random(); int rno = val.Next(12345, 54321); ranno = Convert.ToString(rno); Label22.Text = ranno; RegisterStartupScript("msg", "<script>alert('Your Mail Verification Key is : " + ranno + "')</script>"); password = "[[[Password Removed]]]"; message = "<hr><br>Hello " + "<b>" + TextBox1.Text + " ! </b><br><br>" + "Your Mail Verification Key is : " + "" + ranno + ""; to = TextBox7.Text; NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password); MailMessage msg = new MailMessage(); msg.From = new MailAddress(gMailAccount); msg.To.Add(new MailAddress(to)); msg.Subject = subject; msg.Body = message; msg.IsBodyHtml = true; try { SmtpClient client = new SmtpClient("smtp.gmail.com"); client.EnableSsl = true; client.UseDefaultCredentials = false; client.Credentials = loginInfo; client.Send(msg); } catch (Exception ex) { Console.WriteLine(ex); } yes = "yes"; } }
pre
client.Port = 587; // Gmail works on this port
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)