반응형
DevExpress의 Report의 PDF 문서를 MemoryStream으로 받은 다음에 C#의 SMTP를 이용하여 메일로 전송.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | //using System.Net; //using System.Net.Mail; using (MemoryStream stream = new MemoryStream()) { report.ExportToPdf(stream); byte [] bytes = stream.ToArray(); try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient( "mail.test.co.kr" ); string msg = GetMailTempleate(); msg = msg.Replace( "[MailTitle]" , "발주서 자리" ); msg = msg.Replace( "[name]" , ds.Tables[0].Rows[0][ "USRNM" ].ToString()); //msg = msg.Replace("[Position]", ds.Tables[0].Rows[0][""].ToString()); //msg = msg.Replace("[part]", ""); msg = msg.Replace( "[address]" , ds.Tables[0].Rows[0][ "ADDR" ].ToString()); msg = msg.Replace( "[phone]" , ds.Tables[0].Rows[0][ "OFFICE_TEL" ].ToString()); msg = msg.Replace( "[fax]" , ds.Tables[0].Rows[0][ "FAX_NUM" ].ToString()); mail.From = new MailAddress( "finalwarrior@naver.com" ); mail.To.Add( new MailAddress( "finalwarrior@naver.com" )); mail.Subject = "발주서 명칭???" ; mail.Body = msg; mail.Attachments.Add( new Attachment( new MemoryStream(bytes), "test.pdf" )); //, "application/pdf" mail.IsBodyHtml = true ; SmtpServer.Port = 5878; SmtpServer.Credentials = new System.Net.NetworkCredential( "test@test.co.kr" , "*******" ); SmtpServer.EnableSsl = true ; //SmtpServer.Timeout = 5; SmtpServer.Send(mail); MessageBox.Show( "mail Send" ); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } |
반응형
'C#' 카테고리의 다른 글
.net framework를 이용한 SMTP에 파일첨부해서 보내기 (0) | 2019.01.09 |
---|---|
$ - 문자열 보간 (0) | 2018.11.23 |
System.Drawing.Color Chart (0) | 2018.03.15 |
DataTable Sort(정렬) (0) | 2018.02.13 |
CLR에서 60초 동안 COM 컨텍스트 0x179930에서 COM 컨텍스트 0x179b58(으)로 전환하지 못했습니다. (2) | 2017.07.11 |
댓글