我有一個DataGrid顯示不同的行發送郵件給多個收件人,每個人都有其發送電子郵件到例如ASP.net後點擊
ROW1 COL1日本COL3該行標準 匹配誰多個收件人鏈接COL4(鏈接發送電子郵件給所有日本的用戶)...................
2行COL1瑞典CO3 COL4(鏈接發送電子郵件給所有瑞典的使用者)
現在,當用戶點擊鏈接時,另一個頁面打開,另一個網格視圖控件顯示該行的所有收件人,但在發送電子郵件之前給所有收件人。
問題是,它需要大量的時間,我在想,如果我的做法是錯的我在數據行創建於各行的郵件對象
DataView dv;
if (dv.Count > 0)
{
foreach (DataRow row in dv.Table.Rows)
{
StringBuilder sbEmailBody = new StringBuilder();
sbEmailBody.Append("<div id='mail' style='height:400px;width:750px; padding:10px; margin: 0 auto; '>");
sbEmailBody.Append("Hi " + row["FirstName"].ToString() + ", <br/><br/>");
sbEmailBody.Append("You have registered with siteName, your details match with the following clinical trial.");
sbEmailBody.Append("Please contact the below trial representative for further details</br></br>");
sbEmailBody.Append("<b>Trial Name:</b> " + Session["trialName"].ToString() + "</br>");
sbEmailBody.Append("<b>Contact Name:</b> " + Session["recName"].ToString() + "</br>");
sbEmailBody.Append("<b>Contact Email:</b> " + Session["username"].ToString() + "</br>");
sbEmailBody.Append("<b>Contact Telephone:</b> " + Session["tele"].ToString() + "</br>");
sbEmailBody.Append("<hr> </hr>");
sbEmailBody.Append("<a href='www.sitename.com' style=text-decoration:none><span id='logo' style='font-size:X-Large;font-weight:bold;color:Black;'>siteName</span></a><br/>");
sbEmailBody.Append("<span id='stopEmail' style='font-size:Smaller;'>");
sbEmailBody.Append("if you want to stop receiving emails from sitename please click <a href='www.bbc.co.uk' style=text-decoration:none>here</a>");
sbEmailBody.Append("</span>");
sbEmailBody.Append("</div>");
MailMessage mailMessage = new MailMessage("[email protected]", row["EmailAdd"].ToString());
mailMessage.Subject = "Clinical trial recruiter shown interest in your profile";
mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
mailMessage.Body = sbEmailBody.ToString();
mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(mailMessage);
}
}
你希望我在哪裏調用task.run。目前我的代碼是在頁面加載方法,但我希望頁面被加載,但發送郵件在後臺運行的任務 –
@ GROVER_SYAAN:然後把它放在那裏。 –