private void eMailToolStripMenuItem_Click(object sender, EventArgs e) { Task.Factory.StartNew(() => { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); try { StringBuilder tos = new StringBuilder(); string sUsr = string.Empty; frtEmailsTableAdapter.Fill(miscDataSet.FRT_EMAILS, mktGridView.GetFocusedRowCellValue(colFRTIDS).ToString()); foreach (MiscDataSet.FRT_EMAILSRow row in miscDataSet.FRT_EMAILS.Rows) { MailMessage mail = new MailMessage(); mail.To.Add(row.EMAIL); // Virgulle ayrilmis bircok adres olabilir mail.Subject = mktGridView.GetFocusedRowCellValue(colKONU).ToString(); // string.Format("{From:{1}, Jurnal:{2}, Konu:{0}", jrnMdfylayoutView.GetFocusedRowCellValue(colSUBJECTm).ToString(), Program.USTad, 1); //jrnMdfylayoutView.GetFocusedRowCellValue(colJRNIDm)); mail.Body = mktGridView.GetFocusedRowCellValue(colBODY).ToString(); mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; smtp.Send(mail); } } catch (Exception ex) { MessageBox.Show(this, "Error sending eMail.\n" + ex.ToString()); } }); }
private void eMailExcel(DataRow row) { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); string eMails = row["EMAILS"].ToString(); string eMailSubject = row["EMAILSUBJECT"].ToString(); string eMailBody = row["EMAILBODY"].ToString(); using (MemoryStream memStream = new MemoryStream()) { dGridView.ExportToXls(memStream); // Create a new attachment and put the Excel report into it. memStream.Seek(0, System.IO.SeekOrigin.Begin); System.Net.Mail.Attachment att = new System.Net.Mail.Attachment(memStream, "Tracing.xls", "application/xls"); MailMessage mail = new MailMessage(); mail.Attachments.Add(att); mail.To.Add(eMails); mail.Subject = eMailSubject; mail.Body = eMailBody; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; smtp.Send(mail); mail.Dispose(); } }
private void jrnXF_Load(object sender, EventArgs e) { SMTP = Program.MF.SMTP(); //MainDataSet.SMTPRow SMPTP2 = Program.SMTP2; /* * Qry.qsJrnXF frm = new Qry.qsJrnXF(); * frm.JRN = jurnalDataSet.JRN; * frm.Tbl = RefTbl; * frm.TblPK = RefID; * frm.Dock = DockStyle.Fill; * qsDockPanel.Controls.Add(frm);*/ Qry.qsvJrnXUC frm2 = new Qry.qsvJrnXUC(); frm2.JRN = jurnalDataSet.JRN; frm2.RefTbl = RefTbl; frm2.RefID = RefID; frm2.Dock = DockStyle.Fill; qsDockPanel.Controls.Add(frm2); jrnMdfyGridControl.ExternalRepository = Program.MF.mainPersistentRepository; colTAGSm.ColumnEdit = Program.MF.TAGselJRNrepositoryItemCheckedComboBoxEdit; colMBRSm.ColumnEdit = Program.MF.MBRselRepositoryItemCheckedComboBoxEdit; jrnNewGridControl.ExternalRepository = Program.MF.mainPersistentRepository; colTAGSn.ColumnEdit = Program.MF.TAGselJRNrepositoryItemCheckedComboBoxEdit; colMBRSn.ColumnEdit = Program.MF.MBRselRepositoryItemCheckedComboBoxEdit; initJrnNewRow(); initJrnMdfyRow(); if (!string.IsNullOrEmpty(RefTbl)) { if (RefTbl == "FRT") { string refIDs = jurnalQueriesTableAdapter.FRT_SEL_HDQ_LIST(RefID).ToString(); jrnTableAdapter.Fill(jurnalDataSet.JRN, Program.USR, string.Format("(RefTbl = '{0}' and RefID in ({1})) or (AltTbl='{0}' and AltID in ({1}))", RefTbl, refIDs)); } else { jrnTableAdapter.Fill(jurnalDataSet.JRN, Program.USR, string.Format("REFTBL='{0}' and RefID = {1}", RefTbl, RefID)); } } jrnGridView.FormatConditions[0].Expression = string.Format("Contains([BKMS], '{0}')", Program.USRtag); jrnGridView.ActiveFilterString = string.Format("[UPD_USR] <> '{0}'", Program.USR); jrnGridView.ActiveFilterEnabled = false; Program.MF.XGLrestore(layoutName, 0, jrnGridView); }
private void mailGonderToolStripMenuItem_Click(object sender, EventArgs e) { if (XtraMessageBox.Show("Seçilmiş Firmalara toplu eMail atılacaktır. Eminmisiniz?", "Toplu eMail", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK) { return; } docSelDetTableAdapter.Fill(this.miscDataSet.DOC_SEL_DET, "FRK", frkID, "FRK"); int rowCount = miscDataSet.DOC_SEL_DET.Rows.Count; if (rowCount == 0) { XtraMessageBox.Show("FRK Attachemnt bulunamadı", Text); return; } MiscDataSet.DOC_SEL_DETRow drow = (MiscDataSet.DOC_SEL_DETRow)miscDataSet.DOC_SEL_DET.Rows[0]; byte[] byteArray = drow.BLB; string body = System.Text.Encoding.UTF8.GetString(byteArray, 0, byteArray.Length); MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); mail.Subject = eMailSubjectTextEdit.Text; // Body Attachment dan gelsin mail.Body = body; //mail.Body = eMailBodyRichEditControl.Document.HtmlText; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; foreach (MiscDataSet.FRK_KMPNYRow row in miscDataSet.FRK_KMPNY.Rows) { if (row.SendMail) { send2Firma(smtp, row); } } smtp.Dispose(); }
private void sendEMail(rptInfo rpti, string Caption, XtraReport xr, string eMails, string eMailSubject, string eMailBody) { try { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); MemoryStream mem = new MemoryStream(); xr.ExportToHtml(mem); // Create a new attachment and put the PDF report into it. mem.Seek(0, System.IO.SeekOrigin.Begin); var aaa = Encoding.UTF8.GetString(mem.ToArray()); // Create a new message and attach the PDF report to it. MailMessage mail = new MailMessage(); //mail.Attachments.Add(att); mail.To.Add(eMails); mail.Subject = string.Format("{0} {1}{2}", eMailSubject, rpti.refTO, rpti.refID); mail.Body = aaa; // eMailBody; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; smtp.Send(mail); mem.Close(); // Close the memory stream. Program.MF.reportDone(rpti, false); } catch (Exception ex) { MessageBox.Show(this, "Error sending eMail.\n" + ex.ToString()); } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); string eMails = barEditItem1.EditValue.ToString(); string eMailSubject = "Tunaset PDP Collection Manifest"; //string eMailBody = pvtDataSet.RPR_PG_EMAILS[0].EMAILBODY; using (MemoryStream memStream = new MemoryStream()) { workbook.SaveDocument(memStream, DocumentFormat.Xlsm); //dGridView.ExportToXls(memStream); // Create a new attachment and put the Excel report into it. memStream.Seek(0, System.IO.SeekOrigin.Begin); System.Net.Mail.Attachment att = new System.Net.Mail.Attachment(memStream, "Tunaset_PDP_CollectionManifest.xlsm", "application/xlsm"); MailMessage mail = new MailMessage(); mail.Attachments.Add(att); mail.To.Add(eMails); mail.Subject = eMailSubject; //mail.Body = eMailBody; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; smtp.Send(mail); mail.Dispose(); MessageBox.Show("Mail gönderildi"); } }
private void mailGonderToolStripMenuItem_Click_OLD(object sender, EventArgs e) { if (XtraMessageBox.Show("Seçilmiş Firmalara toplu eMail atılacaktır. Eminmisiniz?", "Toplu eMail", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK) { return; } if (!attDocuments("FRK", frkID)) { return; } MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); mail.Subject = eMailSubjectTextEdit.Text; //mail.Body = eMailBodyRichEditControl.Document.HtmlText; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; foreach (MiscDataSet.FRK_KMPNYRow row in miscDataSet.FRK_KMPNY.Rows) { if (row.SendMail) { send2Firma(smtp, row); } } smtp.Dispose(); }
public static void MailReportTask(rptInfo rpti, string Caption, XtraReport xr, string eMails, string eMailSubject, string eMailBody, string attTyp = "PDF") { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); alertControl1.FormLoad += alertControl1_FormLoad; alertControl1.BeforeFormShow += alertControl1_BeforeFormShow; alertControl1.FormLocation = DevExpress.XtraBars.Alerter.AlertFormLocation.BottomRight; alertControl1.FormShowingEffect = DevExpress.XtraBars.Alerter.AlertFormShowingEffect.MoveHorizontal; alertControl1.AutoFormDelay = 10000; alertControl1.AutoHeight = true; System.Drawing.Bitmap img = Resources.mailForward64; //Resources.ResourceManager.GetObject("mailForward64"); //Bu da OK Task <string> .Factory.StartNew(() => { // Background work try { MemoryStream mem = new MemoryStream(); MailMessage mail = new MailMessage(); System.Net.Mail.Attachment att; if (attTyp == "PDF") { xr.ExportToPdf(mem); mem.Seek(0, System.IO.SeekOrigin.Begin); att = new System.Net.Mail.Attachment(mem, Caption + ".pdf", "application/pdf"); mail.Attachments.Add(att); } else if (attTyp == "RTF") { xr.ExportToRtf(mem); mem.Seek(0, System.IO.SeekOrigin.Begin); att = new System.Net.Mail.Attachment(mem, Caption + ".rtf", "application/rtf"); mail.Attachments.Add(att); } // Create a new message and attach the PDF report to it. mail.To.Add(eMails); mail.Subject = eMailSubject; //string.Format("{0}{1} {2}", rpti.refTO, rpti.refID, eMailSubject); mail.Body = eMailBody; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; smtp.Send(mail); mem.Close(); // Close the memory stream. return(""); } catch (Exception ex) { return(ex.Message); } }).ContinueWith((t) => { // Update UI thread //alertControl1.FormLocation = DevExpress.XtraBars.Alerter.AlertFormLocation.B; if (string.IsNullOrEmpty(t.Result)) { alertControl1.Show(null, Caption, eMails.Replace(",", "\n"), img); Program.MF.reportDone(rpti, false); } else { alertControl1.Show(null, Caption, t.Result, img); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
private void exportSatis(string dil, bool eMail = false) { int tstID = (int)tstGridView.GetFocusedRowCellValue(colTSTIDt); rprTklfTableAdapter.Fill(teklifDataSet.RPR_TKLF, tstID, dil); TeklifDataSet.RPR_TKLFRow rprTklfRow = (TeklifDataSet.RPR_TKLFRow)teklifDataSet.RPR_TKLF.Rows[0]; string tklfTE = "Teklif"; if (dil == "T") { colORGf.Caption = "Çıkış"; colDSTf.Caption = "Varış"; colBRMf.Caption = "Birim"; colTRNTIMEf.Caption = "Transit Süre"; colSKDY.Caption = "KDV%"; colSDVZf.Caption = "Para Birim"; colSFYTf.Caption = "Fiyat"; colSFYT1f.Caption = "Min"; colSFYT2f.Caption = "-45"; colSFYT3f.Caption = "+45"; colSFYT4f.Caption = "+100"; colSFYT5f.Caption = "+250"; colSFYT6f.Caption = "+300"; colSFYT7f.Caption = "+500"; colSFYT8f.Caption = "+1000"; colSFYTE.Caption = "Fiyat"; colSFYT1E.Caption = "Min"; colSFYT2E.Caption = "-45"; colSFYT3E.Caption = "+45"; colSFYT4E.Caption = "+100"; colSFYT5E.Caption = "+250"; colSFYT6E.Caption = "+300"; colSFYT7E.Caption = "+500"; colSFYT8E.Caption = "+1000"; } else { tklfTE = "Tender"; colORGf.Caption = "Origin"; colDSTf.Caption = "Destination"; colBRMf.Caption = "Unit"; colTRNTIMEf.Caption = "Transit Time"; colSKDY.Caption = "%VAT"; colSDVZf.Caption = "Currency"; colSFYTf.Caption = "Rate"; colSFYT1f.Caption = "Min"; colSFYT2f.Caption = "-45"; colSFYT3f.Caption = "+45"; colSFYT4f.Caption = "+100"; colSFYT5f.Caption = "+250"; colSFYT6f.Caption = "+300"; colSFYT7f.Caption = "+500"; colSFYT8f.Caption = "+1000"; colSFYTE.Caption = "Rate"; colSFYT1E.Caption = "Min"; colSFYT2E.Caption = "-45"; colSFYT3E.Caption = "+45"; colSFYT4E.Caption = "+100"; colSFYT5E.Caption = "+250"; colSFYT6E.Caption = "+300"; colSFYT7E.Caption = "+500"; colSFYT8E.Caption = "+1000"; } if (colG9.GroupIndex == 0) { tsfGridView.CollapseAllGroups(); //tsfGridView.OptionsView.ShowFooter = true; tsfGridView.OptionsPrint.ExpandAllGroups = false; tsfGridView.OptionsPrint.PrintFooter = true; //tsfGridView.OptionsPrint.AutoWidth = false; tsfGridView.OptionsPrint.AutoWidth = true; } else { tsfGridView.ExpandAllGroups(); //tsfGridView.OptionsView.ShowFooter = false; tsfGridView.OptionsPrint.ExpandAllGroups = true; tsfGridView.OptionsPrint.PrintFooter = false; //tsfGridView.OptionsPrint.AutoWidth = false; tsfGridView.OptionsPrint.AutoWidth = true; //tsfGridView.BestFitColumns(); } RichEditDocumentServer richServer = new RichEditDocumentServer(); richServer.RtfText = rprTklfRow.ALTNOT; //richServer.Document.AppendText(" SENER"); if (!rprTklfRow.IsDTYNOTNull()) { if (string.IsNullOrEmpty(richServer.Text)) { richServer.RtfText = rprTklfRow.DTYNOT; } else { richServer.Document.AppendRtfText(rprTklfRow.DTYNOT); } } tsfGridView.OptionsPrint.RtfReportFooter = richServer.RtfText; tsfGridView.OptionsPrint.RtfPageFooter = rprTklfRow.FOOTER; PrintingSystem ps = new PrintingSystem(); PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = tsfGridControl; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.Landscape = false; link.Margins.Left = 10; link.Margins.Right = 10; link.Margins.Top = 10; link.Margins.Bottom = 10; // tsfGridView.OptionsPrint.RtfPageHeader = tsfGridView.OptionsPrint.RtfReportHeader = rprTklfRow.USTNOT .Replace("@TSTID@", rprTklfRow.TSTID.ToString()) .Replace("@FIRMA@", rprTklfRow.FIRMA) .Replace("@TLPTRH@", rprTklfRow.TLPTRHS) .Replace("@TKLTRH@", rprTklfRow.TKLTRHS) .Replace("@GCRTRH@", rprTklfRow.GCRTRHS) .Replace("@ROT@", rprTklfRow.ROT) .Replace("@MOT@", rprTklfRow.MOT) .Replace("@PTM@", rprTklfRow.PTM) .Replace("@DTM@", rprTklfRow.DTM) .Replace("@HORGS@", rprTklfRow.HORGS) .Replace("@HDSTS@", rprTklfRow.HDSTS) .Replace("@MORGS@", rprTklfRow.MORGS) .Replace("@MDSTS@", rprTklfRow.MDSTS) .Replace("@MALCINSI@", rprTklfRow["MALCINSI"].ToString()) .Replace("@INFO@", rprTklfRow.INFO); link.CreateDocument(); if (eMail) { if (string.IsNullOrWhiteSpace(rprTklfRow.EMAILS)) { XtraMessageBox.Show("eMail adresi bulunamadı", "eMail Teklif", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } Cursor = Cursors.WaitCursor; try { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); MailMessage mail = new MailMessage(); // Create a new memory stream and export the report into it as PDF. MemoryStream ms = new MemoryStream(); link.ExportToPdf(ms); // Create a new attachment and put the PDF report into it. ms.Seek(0, System.IO.SeekOrigin.Begin); Attachment att = new Attachment(ms, string.Format("{0}-{1}.pdf", tklfTE, tstID), "application/pdf"); mail.Attachments.Add(att); mail.To.Add(rprTklfRow.EMAILS); mail.Subject = rprTklfRow.EMAILSUBJECT; mail.Body = rprTklfRow.EMAILBODY; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); 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; smtp.Send(mail); int len = (int)ms.Length; byte[] img = new byte[len]; ms.Read(img, 0, len); //teklifQueriesTableAdapter.DOC_INS2("TST", tstID, "Teklif", ".pdf", "TKLF", Program.USR, len, img); teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img); // Close the memory stream. ms.Close(); ms.Flush(); rptInfo rpti = new rptInfo(); rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif"); Program.MF.reportDone(rpti, false); } catch (Exception ex) { MessageBox.Show(this, "Error sending eMail.\n" + ex.ToString()); } finally { Cursor = Cursors.Default; } } else { link.ShowPreviewDialog(); if (XtraMessageBox.Show("İşlem tamamlandı mı?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { MemoryStream ms = new MemoryStream(); link.ExportToPdf(ms); ms.Seek(0, System.IO.SeekOrigin.Begin); int len = (int)ms.Length; byte[] img = new byte[len]; ms.Read(img, 0, len); ms.Close(); teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img); rptInfo rpti = new rptInfo(); rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif"); Program.MF.reportDone(rpti, false); } } }
private void MtbktXF_Load(object sender, EventArgs e) { SMTP = Program.MF.SMTP(); }
private void kkSendMailXF_Load(object sender, EventArgs e) { SMTP = Program.MF.SMTP(); this.kKES_TBL_SELTableAdapter.Fill(this.kkDataSet.KKES_TBL_SEL, tbl, refID); }