I have tried many times to make an email app using gmail. I am truly desperate, I have visited the entire Internet even in other languages but I found nothing.
How can I make a email web app in Asp.net c# using gmail?
This is the last code I applied.
try
{
MailMessage ms = new MailMessage();
ms.From = new MailAddress("myemail@gmail.com");
ms.To.Add("fillocj@hotmail.it");
ms.Body = txtTexto.Text;
ms.IsBodyHtml = true;
SmtpClient sm = new SmtpClient();
sm.Host = "smtp.gmail.com";
NetworkCredential nt = new NetworkCredential();
nt.UserName = "myemail@gmail.com";
nt.Password = "myPassword";
sm.UseDefaultCredentials = true;
sm.Credentials = nt;
sm.Port = 465;
sm.EnableSsl = true;
sm.Send(ms);
LabelError.Text = "Sent";
}
catch
{
LabelError.Text = "Error";
}
I always fail over and over again. I tried with port: 25, also with 465 and 587. But any of them works fine. I do not know what the problem is. Please help with this issue.
Aucun commentaire:
Enregistrer un commentaire