Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. // Please note that this was intended for users to enter their email and get a verification email back
  2. // This code was put into a repository to prevent SQL injection, to be even more safe you can enter the email address with password into a second repository
  3.  
  4.  
  5. //Not all of these are essential for SMTP
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Web;
  10. using System.Data;
  11. using System.Data.SqlClient;
  12. using System.Web.UI;
  13. using System.Web.UI.Webcontrols;
  14. using System.Web.Security;
  15. using System.IO;
  16. using System.Text;
  17. using System.Configuration;
  18. using System.Security.Cryptography;
  19. using System.Net.Mail;
  20. using System.net;
  21.  
  22. public partial class _Default : System.Web.UI.Page
  23. {
  24. //button tied to the email sending
  25. protected void btnSend_Click(object sender, EventArgs e)
  26. {
  27. using (MailMessage mail = new MailMessage())
  28. {
  29. mail.From = new MailAddress("123@gmail.com"); //enter whatever email you are sending from here
  30. mail.To.Add(tbEmail.Text); //Text box that the user enters their email address
  31. mail.Subject = "Email Subject"; //enter whatever subject you would like
  32. mail.Body = "<p> Dear ......</p> <br> <p> Enter message here </p>";
  33. mail.IsBodyHtml = true;
  34.  
  35. using (SmtpClient smtp = new smtpClient("123@gmail.com", 587)) //enter the same email that the message is sending from along with port 587
  36. {
  37. smtp.Credentials = new NetworkCredential("123@gmail.com", "Password123"); //Enter email with password
  38. smtp.Enablessl = true;
  39. smtp.Send(mail);
  40. }
  41.  
  42. ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please check the email address you entered for an email')", True);
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement