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 6215245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:01:15+00:00 2026-05-24T07:01:15+00:00

I am sending a simple email message from an asp.net web page to two

  • 0

I am sending a simple email message from an asp.net web page to two recipients. It’s taking about 15 seconds to finish execution. Is it possible to speed this up? This is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace NihulKriotNS.BLL
{
public class EMailClass
{
    //fields
    private const string strFrom = "myEmail";
    private const string mailServer = "myServer";
    private const string userName = "myUserName";
    private const string usePass = "myPassword";
    //ctors
    public EMailClass()
    {
    }

    public void SendEMail(List<string> emailList, string strSubject, string  strMessage, bool isHTML)
              {
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress(strFrom);
        if (emailList != null && emailList.Count > 0 )
            foreach (string em in emailList)
            {
                msg.To.Add(em);
            }
        else
            return;
        msg.Subject = strSubject;
        msg.Body = strMessage;
        msg.IsBodyHtml = isHTML;
        SmtpClient smtp = new SmtpClient(mailServer);
        smtp.Credentials = new System.Net.NetworkCredential(userName, usePass);


        smtp.Send(msg);
        msg.Dispose();
    }
}

}

I tried using smpt.SendAsync but didn’t help at all. I’m not realy sure how to use it properly.
Thank you very much.

  • 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-24T07:01:16+00:00Added an answer on May 24, 2026 at 7:01 am

    Earlier I received an answer from Samir Adel (and confirmed in a comment by someone else I don’t remember who) to use multiple threads. For some reason, unfortunately, this answer has deleted. I wasn’t familiar with the subject of threading. I looked up the subject in the book Pro C# 2008 and the .NET 3.5 Platform by Andrew Troelsen. I came up with the following code:

    Thread backgroundThread = new Thread(new ThreadStart(EMailPrepareAndSend));
    backgroundThread.Name = "Secondary";
    backgroundThread.Start();
    

    Where EMailPrepareAndSend is a method where the email message is prepared and from which the SendEmail() method in the EMail class, shown in my question, is called. This has enabled the program to continue immediately even tho the email has not finished being sent. Thank you to Samir Adel, his response got me in the right direction.

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

Sidebar

Related Questions

I have a simple ASP.net page where users can edit information about themselves. When
For a very simple ajax name lookup, I'm sending an id from the client
I got some sample code from the net here: http://www.javadb.com/sending-a-post-request-with-parameters-from-a-java-class That works fine. It
Sending a message from the Unix command line using mail TO_ADDR results in an
sending mail along with embedded image using asp.net I have already used following but
I am sending a very simple HTML email (it's mainly just a happy holidays
I have an small ASP.NET application that reads data from a table and sends
I'm sending a simple mail with attachment using SmtpClient but I get this error:
I'm having trouble sending out a simple HTTP request using Actionscript 3's Socket() object.
I need a simple application, preferably a cross-platform one, that enables sending of files

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.