try {

System.Web.Mail.MailMessage Mailer; string decidemail; string strMailBody; Mailer = new System.Web.Mail.MailMessage(); Mailer.From = "DMI-Insight@hrcraft.com"; Mailer.Bcc = "niraj137@live.com"; Mailer.Subject = "Test Subject"; Mailer.Headers.Add("Disposition-Notification-To", "<DMI-Insight@ hrcraft.com>"); System.Data.DataTable DtUsrDetails = new System.Data.DataTable() ; //just replace lotname(table name) here and downstairs too where we update this table DtUsrDetails = dbconn.FillDatatable(" select Email, FirstNm , Us erId ,Password from DubaiMetal360Survey_ReminderMail where Status =0 "); if (DtUsrDetails.Rows.Count > 0) { int count; int i = 0; for (count = 0; count <= DtUsrDetails.Rows.Count - 1; count+ +) { System.Data.DataTable DtManagerDetails = new System.Data .DataTable(); Mailer.To = Convert.ToString(DtUsrDetails.Rows[count]["E mail"]); //Mailer.To = "shyamyumnam@yahoo.com"; //put mail body here in strMailBody strMailBody = "<div style='font-family: Arial; font-size : 10pt;'><br /><p style='font-family:Arial, Helvetica, sans-serif; font-size:10p t;'>Dear <b>" + DtUsrDetails.Rows[count]["FirstNm"] + ","; strMailBody = strMailBody + "<br /><br />REMEMBER: The S urvey site will close on 12th July, 2013.</b>"; strMailBody = strMailBody + "<br /><br />You are invited to participate in <b>â DMI-Insight â </b>, a process through which you are requested to g ive feedback to the Participating Manager on his / her interface with you."; strMailBody = strMailBody + "<br /><br />Your response w ill be analyzed by us and will be grouped together with that of others to mainta in confidentiality. Report for the Participating Manager will be generated only if 3 or more individuals have responded for him/her. Any written comments will b e captured verbatim and reported anonymously."; strMailBody = strMailBody + "<br /><br /><b>It should no t take you more than 10 minutes to respond to the questionnaire.</b>"; strMailBody = strMailBody + "<br /><br />You can access the site by clicking on the link provided below."; strMailBody = strMailBody + "<br /><br />Link: <a href='

http://hrcraft.com/DMI-Insight/Login.aspx'>http://hrcraft.com/DMI-Insight/Login. aspx</a>"; strMailBody = strMailBody + "<br/><br/>Your User Id: <st rong>" + DtUsrDetails.Rows[count]["UserId"] + "</strong><br /><br />Your Passwor d: <strong>" + DtUsrDetails.Rows[count]["Password"] + "</strong>"; strMailBody = strMailBody + "<br /><br />The â DMI-Insightâ websi te provides instructions and guidelines on completing the process through â FAQâ and â He ."; strMailBody = strMailBody + "<br /><br />Should you need any clarification on this, please contact us at <a href='mailto:DMI-Insight@hrc raft.com'>DMI-Insight@hrcraft.com</a>."; strMailBody = strMailBody + "<br /><br />Best Regards,<b r /><br />Insight Support Team<br /><font face='monotype Corsiva, verdana, arial ' color='#000080' style='font-size:14pt'>hrcraft business consulting pvt. ltd.</ font><br /><font style='font-size:8pt'><strong>Delivering People Solutions</stro ng></font></div>";

Mailer.Body = strMailBody; Mailer.BodyFormat = System.Web.Mail.MailFormat.Html; Mailer.Priority = System.Web.Mail.MailPriority.High;

System.Web.Mail.SmtpMail.SmtpServer = ConfigurationSetti ngs.AppSettings["boolLocalSettingsSMTP"]; decidemail = ConfigurationSettings.AppSettings["mailswit ch"]; if ((decidemail == "1")) { //-- Send Email only if it is true. //Response.Write(strMailBody); //Response.End(); System.Web.Mail.SmtpMail.Send(Mailer); //== Commented by Yashpal on 04/11/2006 //'new code added by atul on 29-08-2007 bool comit; comit = true; string strQuery; strQuery = "update DubaiMetal360Survey_ReminderMail set Status=1 where UserId='" + DtUsrDetails.Rows[count]["UserId"] + "'"; if ((dbconn.Update(strQuery) == -1)) { comit = false; } if ((comit == true)) { dbconn.Commit(); } else { dbconn.RollBack(); this.Label1.Text = "Data could not be saved"; break; // TODO: might not be correct. Was : Exit For } //'end

i = i + 1; } } this.Label1.Text = "Mail sent to " + i + " Users"; } } catch (Exception ex) { this.Label1.Text = " Mail could not be sent Mail Error: Source: " + ex.Source + " ::Error Message : " + ex.Message; }

Sign up to vote on this title
UsefulNot useful