Hi guys
I'm developing a system that will send emails to supplier with a Quotations# attached to the body of the email. But just before going in deep of my assignment,
I'm currently getting this following error when i'm sending a simple email from my View Page.
System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.206.109:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
Please Anyone Help is very welcome!!!!
It's urgent.
What I have tried:
I have tried this following:
try{
mail.To.Add(obj.ToEmail);
mail.From = new MailAddress("myemail@gmail.com");
mail.Subject = obj.EmailSubject;
mail.Body = obj.EMailBody;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 25);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential("myemail@gmail.com", "password");
smtp.Send(mail);
ViewBag.Status = "Email Sent Successfully.";
}
catch (Exception ex)
{
ViewBag.Status = ex.GetBaseException();
}
return View();
}