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
Cao Cu Hao
NA
22
5.8k
Send email using Gmail SMTP Mail Server in ASP.Net
Jun 30 2015 10:08 PM
Im coded here:
<code>
private void Send()
{
try
{
string Subject = "This is test mail using smtp settings",
Body = "sad",
ToEmail = txtEmail.Text.Trim();
string SMTPUser = "
[email protected]
", SMTPPassword = "myPass";
//Now instantiate a new instance of MailMessage
MailMessage mail = new MailMessage();
//set the sender address of the mail message
mail.From = new MailAddress(SMTPUser, "iDOC");
//set the recepient addresses of the mail message
mail.To.Add(ToEmail);
//set the subject of the mail message
mail.Subject = Subject;
//set the body of the mail message
mail.Body = Body;
//leave as it is even if you are not sending HTML message
mail.IsBodyHtml = true;
//set the priority of the mail message to normal
mail.Priority = MailPriority.Normal;
//instantiate a new instance of SmtpClient
SmtpClient smtp = new SmtpClient();
//if you are using your smtp server, then change your host like "smtp.yourdomain.com"
smtp.Host = "smtp.gmail.com";
//chnage your port for your host
smtp.Port = 25; //or you can also use port# 587
//provide smtp credentials to authenticate to your account
smtp.Credentials = new System.Net.NetworkCredential(SMTPUser, SMTPPassword);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
//if you are using secure authentication using SSL/TLS then "true" else "false"
smtp.EnableSsl = true;
smtp.Send(mail);
}
catch (SmtpException ex)
{
}
}
</code>
Im used port 587
My code is not error but is not work. Any guess what to do?
Thanks
Reply
Answers (
5
)
Getting data of a specific user From SQL
Change placeholder text at run time