i write code for sending mail. Its working fine in local at Execution time. After i Hosted into server. it shows the Error.
A socket operation was attempted to an unreachable host [IP]:587
Please help me how i can solve this problem.
code:
Dim mail As New MailMessage
mail.To.Add("xxx@abc.com")
mail.From = New MailAddress("yyy@gmail.com")
mail.Subject = "Subject"
mail.IsBodyHtml = True
mail.Priority = MailPriority.High
mail.Body = "Testing"
Dim SMTPServer As New SmtpClient("smtp.gmail.com", 587)
Dim nc As System.Net.NetworkCredential = New System.Net.NetworkCredential("EmailID", "Passsword")
SMTPServer.EnableSsl = True
SMTPServer.UseDefaultCredentials = False
SMTPServer.Credentials = nc
SMTPServer.Send(mail)
Session.Clear()