TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Send mail through ASP.NET
Darin
Aug 23
2015
Code
989
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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]
"
;
// Your(Sender's) Email ID
string
SenderPassword =
"********"
;
// Your Password
string
Reciever_id = TextBox1.Text;
// Reciever's Email ID
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 "
);
// (SUBJECT = Subject of the mail)
// (BODY = Message or 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.
ASP.NET
Mail