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
Photo

ASP.NET - Error in sending Email from Google Apps


  • Please log in to reply

#1
Goinfory

Goinfory

    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("utility@mydomain.com", "GotFeedback", System.Text.Encoding.UTF8);
    mMailMessage.To.Add(new MailAddress("feedback@mydomain.com"));
    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("utility@mydomain.com", "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!


  • 0

Advertisements


#2
azarl

azarl

    GeekU Admin

  • Administrator
  • 24,934 posts

Try changing

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

to

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