Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Please note that this was intended for users to enter their email and get a verification email back
- // 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
- //Not all of these are essential for SMTP
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Data;
- using System.Data.SqlClient;
- using System.Web.UI;
- using System.Web.UI.Webcontrols;
- using System.Web.Security;
- using System.IO;
- using System.Text;
- using System.Configuration;
- using System.Security.Cryptography;
- using System.Net.Mail;
- using System.net;
- public partial class _Default : System.Web.UI.Page
- {
- //button tied to the email sending
- protected void btnSend_Click(object sender, EventArgs e)
- {
- using (MailMessage mail = new MailMessage())
- {
- mail.From = new MailAddress("123@gmail.com"); //enter whatever email you are sending from here
- mail.To.Add(tbEmail.Text); //Text box that the user enters their email address
- mail.Subject = "Email Subject"; //enter whatever subject you would like
- mail.Body = "<p> Dear ......</p> <br> <p> Enter message here </p>";
- mail.IsBodyHtml = true;
- using (SmtpClient smtp = new smtpClient("123@gmail.com", 587)) //enter the same email that the message is sending from along with port 587
- {
- smtp.Credentials = new NetworkCredential("123@gmail.com", "Password123"); //Enter email with password
- smtp.Enablessl = true;
- smtp.Send(mail);
- }
- ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please check the email address you entered for an email')", True);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement