ASP.Net : Error in sending EMail from Google Apps hosted at Godaddy
- by user279244
Hello,
I want to send EMail from my Website hosted at GoDaddy, and we are using Google Apps for Emails.
Here is my code in ASP.Net/ C#
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress("[email protected]", "GotFeedback", System.Text.Encoding.UTF8);
mMailMessage.To.Add(new MailAddress("[email protected]"));
mMailMessage.Subject = "subject";
mMailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
mMailMessage.Body = body;
mMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mMailMessage.IsBodyHtml = true;
mMailMessage.Priority = MailPriority.Normal;
SmtpClient mSmtpClient = new SmtpClient();
mSmtpClient.UseDefaultCredentials = false;
mSmtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "mypassword");
mSmtpClient.Host = "SMTP.GOOGLE.COM";
mSmtpClient.Port = 587;
mSmtpClient.EnableSsl = true;
try
{
mSmtpClient.Send(mMailMessage);
}
catch(Exception e)
{
string edsf = e.ToString();
}
But I am getting Exception that it is unable to connect to remote server.
Please help.
Thanks