Hi,
I send e-mails with the method I prepared. In the content of this e-mail, there is an html table containing the records responsible for the persons to be sent. However, at the moment, the mail is not sent in a private way. In other words, the mail sent to the people sends not only the records of the relevant person, but also the records of other people. However, for example, I want only data related to the records that he is responsible for to be sent to the person named x. I think for that, I need to check that the next record does not belong to the person concerned and exit the loop if the condition is valid. And then I have to loop again and continue from the next user. But somehow I could not achieve the result I wanted. I ask for your help.
- private void SendMailIfNoComment()
- {
- using (SqlConnection conn = new SqlConnection(myDbConnect))
- {
- using (SqlCommand cmd = new SqlCommand("sp_CheckIfaCommentHasBeenMade", conn))
- {
- cmd.CommandType = CommandType.StoredProcedure;
- int mailsayac = 0;
- DataSet ds = new DataSet();
- SqlDataAdapter adp = new SqlDataAdapter();
- adp.SelectCommand = cmd;
- adp.Fill(ds);
- string MailSubject = string.Empty, danismanMail = string.Empty, MailBody = string.Empty, IstekTarihi = string.Empty, MailFrom = "xxx";
- int i;
- if (ds.Tables[0].Rows.Count > 0)
- {
- MailSubject = "xxx";
- MailBody = "<table style=\"border:0px;width:900px;font-family:Arial;font-size:12px;\"><tr>";
- MailBody += "<td valign=\"top\" style=\"font-weight:bold;width:100px;border:1px solid navy\">Istek No</td>";
- MailBody += "<td valign=\"top\" style=\"font-weight:bold;width:400px;border:1px solid navy\">Istek</td>";
- MailBody += "<td valign=\"top\" style=\"font-weight:bold;width:100px;border:1px solid navy\">Sorumlu Danisman</td>";
- MailBody += "<td valign=\"top\" style=\"font-weight:bold;width:100px;border:1px solid navy\">Istek Sorumlusu</td>";
- MailBody += "<td valign=\"top\" style=\"font-weight:bold;width:100px;border:1px solid navy\">Istek Durumu</td>";
- MailBody += "<td valign=\"top\" style=\"font-weight:bold;width:100px;border:1px solid navy\">Istek Tarihi</td>";
- MailBody += "";
- mailsayac = 0;
- foreach (DataRow row in ds.Tables[0].Rows)
- {
- danismanMail = row["DanismanMail"].ToString();
- IstekTarihi = string.IsNullOrEmpty(row["istek_tarihi"].ToString()) == false ? string.Format("{0:dd.MM.yyyy}", row["istek_tarihi"]) : string.Empty;
- MailBody += "<tr><td valign=\"top\" style=\"width:100px;border:1px solid navy\"><href="" + row["IstekNo"].ToString() + "\">" + row["IstekNo"].ToString() + "</a></td>";
- MailBody += "<td valign=\"top\" style=\"width:400px;border:1px solid navy\">" + row["istek"].ToString() + "</td>";
- MailBody += "<td valign=\"top\" style=\"width:100px;border:1px solid navy\">" + row["Danisman"].ToString() + "</td>";
- MailBody += "<td valign=\"top\" style=\"width:100px;border:1px solid navy\">" + row["IstekSorumlusu"].ToString() + "</td>";
- MailBody += "<td valign=\"top\" style=\"width:100px;border:1px solid navy\">" + row["durum"].ToString() + "</td>";
- MailBody += "<td valign=\"top\" style=\"width:100px;border:1px solid navy\">" + IstekTarihi + "</td>";
- mailsayac++;
- }
- MailBody += "</table>";
- if (mailsayac > 0) MailUtils.SendMail(MailSubject, MailFrom, danismanMail.Split(';'), "smtp.yandex.com.tr", MailBody, true, Session["UserEmail"].ToString());
- }
- }
- }
- }