Hi makumbi,
There is no way to show the progress of the send email.
You can use Ajax UpdatePanel and UpdateProgress controls to show loading progress indicator using GIF image.
On send email button click gif processing image will be displayed till the process is occurring.
Refer below sample code.
HTML
<style type="text/css">
body {
margin: 0;
padding: 0;
font-family: Arial;
}
.modal {
position: fixed;
z-index: 999;
height: 100%;
width: 100%;
top: 0;
background-color: Black;
filter: alpha(opacity=60);
opacity: 0.6;
-moz-opacity: 0.8;
}
.center {
z-index: 1000;
margin: 300px auto;
padding: 10px;
width: 130px;
background-color: White;
border-radius: 10px;
filter: alpha(opacity=100);
opacity: 1;
-moz-opacity: 1;
}
.center img {
height: 128px;
width: 128px;
}
</style>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="loader.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnSend" Text="Send Email" runat="server" OnClick="OnSendEmail" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSend" />
</Triggers>
</asp:UpdatePanel>
<script type="text/javascript">
window.onsubmit = function () {
var updateProgress = $find("<%= UpdateProgress1.ClientID %>");
window.setTimeout(function () {
updateProgress.set_visible(true);
}, 100);
}
</script>
Namespaces
C#
using System.IO;
using System.Net;
using System.Net.Mail;
VB.Net
Imports System.IO
Imports System.Net
Imports System.Net.Mail
Code
C#
protected void OnSendEmail(object sender, EventArgs e)
{
MailMessage mm = new MailMessage("sender@gmail.com", "receiver@gmail.com");
mm.Subject = "Test Subject";
mm.Body = "Test Body"
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential();
NetworkCred.UserName = "sender@gmail.com";
NetworkCred.Password = "password";
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
VB.Net
Protected Sub OnSendEmail(ByVal sender As Object, ByVal e As EventArgs)
Dim mm As MailMessage = New MailMessage("sender@gmail.com", "receiver@gmail.com")
mm.Subject = "Test Subject"
mm.Body = "Test Body"
mm.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.EnableSsl = True
Dim NetworkCred As NetworkCredential = New NetworkCredential()
NetworkCred.UserName = "sender@gmail.com"
NetworkCred.Password = "password"
smtp.UseDefaultCredentials = True
smtp.Credentials = NetworkCred
smtp.Port = 587
smtp.Send(mm)
End Sub