i am trying to avoid the wait time, taken by sending an email before exiting page.
the page/application is doing a sequence of actions before exiting as follows :
- database interaction
- Send Email (updates a manager about that transaction)
- Exit page / application .
code behind function :
ExecEntryOnTbl(SQL);// <-- update / insert to database
sendMailNote(action);// <-- send mail with notification of update
exitTC(action, custid);<-- exit page.
done via javascript :
window.location.href = "someOtherPage.aspx"
from code behind via
RegisterClientScriptBlock(...)
i would like to solve the issue :
how can i avoid waiting for the sendMailNote()
to complete
before following exitTC()
could be executed. is that possible ?
update email class/method
public static class mail { public static string aReciver, bSubject, cBody; public static void sendMailNoteExc() { string SmtpServer = "smtp.gmail.com"; int port = 111; string sender = "aaa@bbb.com"; string ReCiver = aReciver; string Subject = bSubject; string Body = cBody; string account = "acc@domain.com"; string Pass = "a123456"; Send(SmtpServer, port, account, Pass, sender, ReCiver, Subject, Body); } public static void Send(string smtpServer,int Port,string Account, string PassWord, string From, string To, string Subject, string Body) { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient(smtpServer); mail.From = new MailAddress(From); mail.To.Add(To); mail.Subject = Subject; mail.Body = Body; SmtpServer.Port = Port; SmtpServer.Credentials = new System.Net.NetworkCredential(Account, PassWord); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } }