ASP.Net : Error in sending EMail from Google Apps hosted at Godaddy

Posted by user279244 on Stack Overflow See other posts from Stack Overflow or by user279244
Published on 2010-06-02T20:50:55Z Indexed on 2010/06/02 20:54 UTC
Read the original article Hit count: 251

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET