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
sandeep sandy
NA
18
7.3k
sending mail from gmail
May 12 2016 8:19 AM
Hii,
i am facing the following error while sending the mail following is my code please help
“The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
thanks in advance
-----------------------------------------------------------------------------------------------
protected
void
btnSubmit_Click(
object
sender,
EventArgs
e)
{
try
{
MailMessage
Msg =
new
MailMessage
();
// Sender e-mail address.
Msg.From =
new
MailAddress
(txtUsername.Text);
// Recipient e-mail address.
Msg.To.Add(txtTo.Text);
Msg.Subject = txtSubject.Text;
Msg.Body = txtBody.Text;
// your remote SMTP server IP.
SmtpClient
smtp =
new
SmtpClient
();
smtp.Host =
"smtp.gmail.com"
;
smtp.Port = 587;
smtp.Credentials=
new
System.Net.
NetworkCredential
(txtUsername.Text,txtpwd.Text);
smtp.EnableSsl =
true
;
smtp.Send(Msg);
Msg =
null
;
Page.RegisterStartupScript(
"UserMsg"
,
"<script>alert('Mail sent thank you...');if(alert){ window.location='SendMail.aspx';}</script>"
);
}
catch
(
Exception
ex)
{
Console
.WriteLine(
"{0} Exception caught."
, ex);
}
}
-----------------------------------------------------------------------------------------------------------
Reply
Answers (
3
)
asp.net gridview
DEBUG TO RELEASE OPTION