Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

ASP.NET - Error in sending Email from Google Apps

  • Please log in to reply



    New Member

  • Member
  • Pip
  • 1 posts

Hello, I want to send Email from my Website hosted at hostforlife.eu, 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;
    catch(Exception e)
        string edsf = e.ToString();

But I am getting Exception that it is unable to connect to remote server :( Please help. Thanks!

  • 0




    GeekU Admin

  • Community Leader
  • 25,310 posts

Try changing

mSmtpClient.Host = "SMTP.GOOGLE.COM";


mSmtpClient.Host = "SMTP.mydomain.com";

Or try this code

  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP