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

  • SEARCH
  • Home
  • 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 811461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:02:58+00:00 2026-05-15T01:02:58+00:00

I have an application that uses SmtpClient to send E-Mail, but the E-Mails are

  • 0

I have an application that uses SmtpClient to send E-Mail, but the E-Mails are not sent until the application closes. I have searched and searched to find a solution to the problem, but I am not able to find one.

The system does have Symantec anti-virus installed, which could possibly be the problem.

Does anybody have a solution to this problem?

Here is the code I am using.

public class EMail
{
    private string server;
    public string Server {get{return this.server;}set{this.server = value;}}
    private string to;
    public string To {get{return this.to;}set{this.to = value;}}
    private string from;
    public string From {get{return this.from;}set{this.from = value;}}
    private string subject;
    public string Subject {get{return this.subject;}set{this.subject = value;}}
    private string body;
    public string Body {get{return this.body;}set{this.body = value;}}

    public EMail()
    {}
    public EMail(string _server, string _to, string _from, string _subject, string _body)
    {
        this.Server = _server;
        this.To = _to;
        this.From = _from;
        this.Subject = _subject;
        this.Body = _body;
    }   

    public void Send()
    {
        using(System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(this.From, this.To, this.Subject, this.Body))
        {        
            message.IsBodyHtml = true;
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(this.Server);
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            //I have tried this, but it still does not work.
            //client.ServicePoint.ConnectionLeaseTimeout = 0;
            try 
            {
                client.Send(message);
            }  
            catch(System.Exception ex) 
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());              
            }
        }
    }
}

Edit:

It turns out the email does eventually send after 2-3 minutes. It seems as though it is being queued by the exchange server, or the SmtpClient connection eventually times out and is closed by the server.

Edit:

I have tried.

client.ServicePoint.ConnectionLeaseTimeout = 1;
client.ServicePoint.MaxIdleTime = 1;
  • 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-15T01:02:58+00:00Added an answer on May 15, 2026 at 1:02 am

    I finally; after all the help from StackOverflow and other various research sources, have found the solution. By setting System.Net.ServicePointManager.MaxServicePointIdleTime = 1, the mail is sent immediately.

    Here is the final code.

    public class EMail
    {
        private string server;
        public string Server {get{return this.server;}set{this.server = value;}}
        private string to;
        public string To {get{return this.to;}set{this.to = value;}}
        private string from;
        public string From {get{return this.from;}set{this.from = value;}}
        private string subject;
        public string Subject {get{return this.subject;}set{this.subject = value;}}
        private string body;
        public string Body {get{return this.body;}set{this.body = value;}}
    
        public EMail()
        {}
        public EMail(string _server, string _to, string _from, string _subject, string _body)
        {
            this.Server = _server;
            this.To = _to;
            this.From = _from;
            this.Subject = _subject;
            this.Body = _body;
        }   
    
        public void Send()
        {
            using(System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(this.From, this.To, this.Subject, this.Body))
            {        
                message.IsBodyHtml = true;
                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(this.Server);
                client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    
                int temp = System.Net.ServicePointManager.MaxServicePointIdleTime; //<- Store the original value.
                System.Net.ServicePointManager.MaxServicePointIdleTime = 1; //<- Change the idle time to 1.
    
                try 
                {
                    client.Send(message);
                }  
                catch(System.Exception ex) 
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString());              
                }
                finally
                {
                    System.Net.ServicePointManager.MaxServicePointIdleTime = temp; //<- Set the idle time back to what it was.
                }
            }
        }
    }
    

    Thank you all for your help! Especially icemanind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.