Want to build the ChatGPT based Apps? Start here
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Raja Priya Meganathan
2k
194
4.1k
Trying to send the message to my Gmail account.
Mar 1 2021 1:00 PM
I'm trying to send the message to my Gmail account through SMTP. And here is my code.
try
{
MailMessage msg =
new
MailMessage();
msg.From =
new
MailAddress(
"From@gmail.com"
);
msg.To.Add(
"to.aitech@gmail.com"
);
msg.Subject =
"test"
;
msg.Body =
"Test Content"
;
msg.Priority = MailPriority.High;
SmtpClient client =
new
SmtpClient();
client.UseDefaultCredentials =
false
;
client.Credentials =
new
NetworkCredential(
"From@gmail.com"
,
"123"
,
"smtp.gmail.com"
);
client.Host =
"smtp.gmail.com"
;
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl =
true
;
client.Send(msg);
}
catch
(Exception ex)
{
throw
ex;
}
It's throwing the exception "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required"
Reply
Answers (
6
)
Can I develop hotspot file sharing desktop application with c#?
Default printer setting is changed in windows.