- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Net.Mail;
- namespace WebApplication1 {
- public partial class Frm_ForgotPassword: System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e) {}
- protected void Button1_Click(object sender, EventArgs e)
- {
- try {
- string Senderid = "[email protected]";
- string SenderPassword = "********";
- string Reciever_id = TextBox1.Text;
-
- SmtpClient smtp = new SmtpClient() {
- Host = "smtp.gmail.com",
- Port = 587,
- EnableSsl = true,
- DeliveryMethod = SmtpDeliveryMethod.Network,
- Credentials = new System.Net.NetworkCredential(Senderid, SenderPassword),
- Timeout = 30000,
- };
-
- MailMessage message = new MailMessage(Senderid, Reciever_id, "SUBJECT", "BODY ");
-
-
-
- smtp.Send(message);
- Response.Write("Mail Sent Successfully");
- }
- catch (Exception ex)
- {
- ex.Message.ToString();
- }
- }
- }
- }
Note: Only the subject and the body changes as per application. You can integrate this code for Email Verification, Forgot Password,etc