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 = "
";"; - MailBody += "
Istek No ";- MailBody += "
Istek ";- MailBody += "
Sorumlu Danisman ";- MailBody += "
Istek Sorumlusu ";- MailBody += "
Istek Durumu ";- MailBody += "
Istek Tarihi ";- 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 += "
";" + row["IstekNo"].ToString() + "\">" + row["IstekNo"].ToString() + " - MailBody += "
" + row["istek"].ToString() + " ";- MailBody += "
" + row["Danisman"].ToString() + " ";- MailBody += "
" + row["IstekSorumlusu"].ToString() + " ";- MailBody += "
" + row["durum"].ToString() + " ";- MailBody += "
" + IstekTarihi + " ";- mailsayac++;
- }
- MailBody += "
- MailBody += "
- if (mailsayac > 0) MailUtils.SendMail(MailSubject, MailFrom, danismanMail.Split(';'), "smtp.yandex.com.tr", MailBody, true, Session["UserEmail"].ToString());
- }
- }
- }
- }
Sachin SinghPosted Feb 23, 2021, 4:53 PM
Rijwan AnsariPosted Feb 23, 2021, 4:15 PM