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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shubhangi khandale
NA
73
147.4k
How to config smtp server
Apr 13 2012 7:05 AM
Hi,
I have create web application send mail. i use this code
con.Open();
com = new SqlCommand("select mailid,password='" + TextBox2.Text + "' from registration where userid='" + TextBox1.Text + "'", con);
dr = com.ExecuteReader();
if (dr.Read())
{
mid = dr["mailid"].ToString();
var fromAddress = new MailAddress("
[email protected]
", "Cloud Storage");
var toAddress = new MailAddress(mid, "Cloud Storage");
const string fromPassword = "pa$$word123";
const string subject = "Verification Code";
int n = _r.Next();
body = n.ToString();
Session["msg"] = body.ToString();
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
//smtp.Send(message);
}
Session["Username"] = TextBox1.Text.ToString();
Response.Redirect ("Verification.aspx");
}
else
{
Response.Write("Invalid Login");
}
but error at not remote server (sending failed) so how to set smtp server
Reply
Answers (
8
)
Unable to evaluate expression because the code is optimized
Get Text of Gridview TextBox on button click