locked
send email asynchronously RRS feed

  • Question

  • User-381059448 posted

    WHEN I CLICK ON THE BUTTON SEND (MAIL) I do not have to leave the page of sending since 3 minutes to receive a mail.
    but I need to browse my site (leave the page of " sending mail" ) and receive a mail anyway.
    and for that I use a backgroundthread but it not work

    help me please

     Thread email = new Thread(delegate ()
                     {
                     System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                     client.Host = sSMTPHost;
                     System.Net.NetworkCredential basicauthenticationinfo = new System.Net.NetworkCredential(sSender, sSenderPassword);
                     client.Port = int.Parse(sSMTPPort);
                     client.EnableSsl = true;
                     client.UseDefaultCredentials = false;
                     client.Credentials = basicauthenticationinfo;
                     client.DeliveryMethod = SmtpDeliveryMethod.Network;
                     client.Send(objMailMsg);
    
                    });
                   
                    email.IsBackground = true;
                    email.Start();
                    }
    
                HiddenFiledSendRejectMailsLoopCondition.Value = "0";
            }
    

    Sunday, September 2, 2018 3:44 PM

Answers

  • User-821857111 posted

    You don't need a background thread. Once you initiate the sending of an email, you can navigate to other pages without affecting the process. It won't get cancelled if you leave the page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 2, 2018 7:52 PM

All replies

  • User-821857111 posted

    You don't need a background thread. Once you initiate the sending of an email, you can navigate to other pages without affecting the process. It won't get cancelled if you leave the page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 2, 2018 7:52 PM
  • User-381059448 posted

    thanks Mikesdotnett

    what should I do????

    Sunday, September 2, 2018 8:42 PM
  • User-821857111 posted

    Just send the email normally.

    Monday, September 3, 2018 7:07 AM