The problems here are several.
1. You use an internal cms page, which does not have <@Page Async="True" .. /> attribute.
2. smtp.SendCompleted += new SendCompletedEventHandler(SmtpClient_OnCompleted);
You are calling a delegate, but what will happen with the event when the main thread completes?
There are several solutions:
1. To make the page Asynchronous. There are two ways for doing this, but it is not a good solution, since the client will have no response from the server until all threads related to that page are completed. Sending the e-mails can take quite a lot of time, and we do not want the client browser to wait that long. Still, here are the solutions:
- Assign this page a master page, having the Async="True attribute
- Creating a new class in the App_Code directory, inheriting from InternalPage class. Then, making your cms internal pages to inherit your new class by tweaking the Sitefinity\cmsentrypoint.aspx:
Then you can check if the user is on the page you want, and add the Async attribute (make the page assynchronous)
|<%@ Page Inherits="YourInternalPageClass" MasterPageFile="~/Sitefinity/Dummy.master" %>
2. To use the web service. This is the preffered choice - you can read the status of the sending and notify the user at any given time. By this approach, you will not make the user to wait until the sending is complete.
3. By Ajax requests. On each call you will send one e-mail - the user interface will be still responsive.
Here are a couple of resources that might help you as well:
I hope you find this information helpful.
the Telerik team
, the state of the art learning tool for Telerik products.