private void send2Firma(SmtpClient smtp, AccountRprDataSet.ACC_MTBKT_LISTRow row) { string eMails = row.EMAILS; if (!string.IsNullOrEmpty(Program.USReMail)) { eMails += ", " + Program.USReMail; // Aktif usera da mail gonder Control } string fn = "Mutabakat.pdf"; MemoryStream ms = new MemoryStream(); if (turRadioGroup.SelectedIndex == 0) { tMax14ReportClassLibrary.MtbktXR rpr = new tMax14ReportClassLibrary.MtbktXR(row.FRTID, dateEdit1.DateTime); rpr.ExportToPdf(ms); } else { tMax14ReportClassLibrary.Mtbkt_BaBsXR rpr = new tMax14ReportClassLibrary.Mtbkt_BaBsXR(row.FRTID, dateEdit1.DateTime); rpr.ExportToPdf(ms); } ms.Seek(0, System.IO.SeekOrigin.Begin); var attachment = new Attachment(ms, fn); try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); mail.To.Add(eMails); mail.Subject = eMailSubjectTextEdit.Text; mail.Body = eMailBodyRichEditControl.Document.HtmlText; mail.IsBodyHtml = true; mail.Attachments.Add(attachment); smtp.Send(mail); mail.Dispose(); row.SendMail = false; row.SendStatu = (int)sendStatu.Gonderildi; accountRprQueriesTableAdapter.RPH_INS(rptRow.KOD, "FRT", row.FRTID, Program.USR, "F", null); } catch (Exception ex) { row.SendStatu = (int)sendStatu.Gonderilemedi; row.SendMsj = ex.Message; } }
private void eMailTekToolStripMenuItem_Click(object sender, EventArgs e) { SmtpClient smtp = new SmtpClient(SMTP.CLIENT_HOST); smtp.Credentials = new System.Net.NetworkCredential(SMTP.CREDENTIALS_USER_NAME, SMTP.CREDENTIALS_USER_PASSWORD); smtp.EnableSsl = SMTP.ENABLE_SSL == "T" ? true : false; smtp.Port = SMTP.PORT; int sri = mtbktGridView.GetFocusedDataSourceRowIndex(); AccountRprDataSet.ACC_MTBKT_LISTRow row = (AccountRprDataSet.ACC_MTBKT_LISTRow)accountRprDataSet.ACC_MTBKT_LIST.Rows[sri]; if (row.SendStatu == (int)sendStatu.Gonderilemez) { XtraMessageBox.Show("Gonderilemez", "Send eMail"); } else { send2Firma(smtp, row); } smtp.Dispose(); }