0

I want to send mail to large number fast asp.net....It takes some time for me...My code as follows

string s14 = "select  email from  CandidateReg1";
         // string s14 = "select top 2 email from  CandidateReg1";
           DataTable d7 = cn.viewdatatable(s14);

           for (int m = 0; m < d7.Rows.Count; m++)
           {
               email = d7.Rows[m]["email"].ToString();
               sendmail();

           }
 Collapse | Copy Code
private void sendmail()
    {
        string s43 = "select top 1 mailid,password from EmailTable order by id desc";
        DataTable d47 = cn.viewdatatable(s43);
        for (int k = 0; k < d47.Rows.Count; k++)
        {

            companymailid = d47.Rows[k]["mailid"].ToString();
            password = d47.Rows[k]["password"].ToString();

        }
        SmtpClient smtp = new SmtpClient();
        smtp.Host = ConfigurationManager.AppSettings["SMTPServer"];
        //smtp.Port = 587;
        //smtp.EnableSsl = true;
        //smtp.UseDefaultCredentials = true;
        //if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["SMTPCredentialUser"]) && !string.IsNullOrEmpty(ConfigurationManager.AppSettings["SMTPCredentialPass"]))
        //{
        //    smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["SMTPCredentialUser"], ConfigurationManager.AppSettings["SMTPCredentialPass"]);
        //}
        smtp.Credentials = new System.Net.NetworkCredential(companymailid, password);

        MailMessage message = new MailMessage();
        // message.From = new MailAddress(companymailid);
        message.From = new MailAddress(companymailid);
        message.Subject = "Job Published";
        message.IsBodyHtml = true;
        StringBuilder body = new StringBuilder();
        body.Append("<table>");

        //body.Append("<tr><td>" + pass + "</td></tr>");

        body.Append("<tr><td>Published Job " + Session["jobtitle"].ToString() + ' ' + "with JobRefId (" + ' ' + Session["jobrefid"].ToString() + ')' + "</td></tr>");

        body.Append("</table>");
        body.Append("<br />");
        body.Append("<br />");
        body.Append("Sincerely,<br />");
        body.Append("<span style=\"font-weight: bold; color: #000099;\">Team - ResumeManager</span>");
        body.Append("<br />");
        body.Append("<br />");

        message.Body = body.ToString();
        message.To.Add(email);

        //message.To.Add("korathualex@gmail.com");
        try
        {
            smtp.Send(message);
            popupConfirm.ShowOnPageLoad = false;
            PopUpSendMailMsg.ShowOnPageLoad = true;
            lblmsg.Visible = false;
            lblmsgsendmail.Visible = true;
            lblmsgsendmail.Text = "Mail Send Successfully";

        }
        catch (Exception ex)
        {
            cn.WriteError(ex.Message);
        }
3
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by pritaeas
0

I want to send mail to large number fast asp.net....It takes some time for me...My code as follows

How long does it take for you send that much?

I assume it's actually sending emails?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.