Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3611110
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:50:11+00:00 2026-05-18T21:50:11+00:00

I am trying to send an email via GMail from ASP.Net using the code

  • 0

I am trying to send an email via GMail from ASP.Net using the code and config below. Unfortunatly it doesn’t seem to be working and it also isn’t throwing an error message. There is nothing in the server logs or the mail IIS mail folders, I even checked the trash of the from address to see if the mail ended up there. Any help would be really appreciated.

C# Section

    public void SendFeedback()
    {
        string emailFrom = this.Email.Text;

        MailMessage message = new MailMessage();
        // here is an important part:
        message.From = new MailAddress(emailFrom, "Mailer");
        // it's superfluous part here since from address is defined in .config file
        // in my example. But since you don't use .config file, you will need it.
        message.Subject = "www.gumpshen.com - Website Query";
        message.IsBodyHtml = true;
        message.Body = string.Format(" Name = {0}, Phone = {1}", Name.Text, Phone.Text);
        message.Body += Environment.NewLine;
        message.Body += Environment.NewLine;
        message.Body += ProjectDetails.Text; ;

        var client = new SmtpClient();

        try
        {
            client.Send(message);

This is the Config section:

<system.net>
  <mailSettings>
    <smtp from="myEmail@gmail.com" deliveryMethod="Network" >
      <network host="smtp.gmail.com" port="587" 
        userName="myEmail@gmail.com" password="myPassword"/>
    </smtp>
  </mailSettings>
</system.net>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:50:12+00:00Added an answer on May 18, 2026 at 9:50 pm

    You need client.EnableSsl=true;

    Check the code from this site: Email via Gmail

    Here is an example on how to send HTML email from your ASP.NET page using your Google account.
    (This setup can be easily used to send messages via any other SMTP server that requires authentication).
    Note: the code snippet assumes you have a Label component on Page with named lblMsg that will show
    success/failure message to the user that is sending email.
    (But this can be easily changed).

       SmtpClient client = new SmtpClient();
       client.DeliveryMethod = SmtpDeliveryMethod.Network;
       client.EnableSsl = true;
       client.Host = "smtp.gmail.com";
       client.Port = 587;
    
       // setup Smtp authentication
       System.Net.NetworkCredential credentials = 
           new System.Net.NetworkCredential("your_account@gmail.com", "yourpassword");
       client.UseDefaultCredentials = false;
       client.Credentials = credentials;                
    
       MailMessage msg = new MailMessage();
       msg.From = new MailAddress("your_account@gmail.com");
       msg.To.Add(new MailAddress("destination_address@someserver.com"));
    
       msg.Subject = "This is a test Email subject";
       msg.IsBodyHtml = true;
       msg.Body = string.Format("<html><head></head><body><b>Test HTML Email</b></body>");
    
       try
       {
           client.Send(msg);
           lblMsg.Text = "Your message has been successfully sent.";
       }
       catch (Exception ex)
       {
           lblMsg.ForeColor = Color.Red;
           lblMsg.Text = "Error occured while sending your message." + ex.Message;
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send an email via some C# ASP.NET code. This is being
I am trying to send an email via GMail's SMTP server from a PHP
I'm trying to send an email via asp.net mvc2, and all works well on
I'm trying to send an email message using the .NET MailMessage class which can
I am trying to send email through gmail using PHPMailer_V5.1. Getting the following error,
I am trying to send an email from a site I am building, but
I'm trying to automatically retrieve some email from my GMail account for further parsing,
I'm trying to send simple email via Ruby (no rails) on OS X, with
I am trying to send email using mail() in php. I need the message
I'm using Grails Mail plugin and trying to send email and keep getting: Error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.