Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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("[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!


  • 0

Advertisements


#2
azarl

azarl

    GeekU Admin

  • Community Leader
  • 25,310 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