From de5a759902a07eab134963d7aa1960c77221f7e6 Mon Sep 17 00:00:00 2001 From: ChiKyun Kim Date: Tue, 12 Aug 2025 17:10:34 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EC=9D=BC=EC=84=9C=EB=B9=84=EC=8A=A4?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=20=EA=B0=95=ED=99=94=20=EB=B0=8F=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sub/Console_SendMail/_MailService.cs | 40 +++++++++++++++++++--------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Sub/Console_SendMail/_MailService.cs b/Sub/Console_SendMail/_MailService.cs index 9f729b9..e042951 100644 --- a/Sub/Console_SendMail/_MailService.cs +++ b/Sub/Console_SendMail/_MailService.cs @@ -1082,7 +1082,7 @@ namespace Console_SendMail var email_design = DatabaseManager.GetUserEmail(vGcode, IdDesign); var email_epanel = DatabaseManager.GetUserEmail(vGcode, IdEPanel); var email_software = DatabaseManager.GetUserEmail(vGcode, IdSoftware); - if (string.IsNullOrEmpty(email_champion) ==false && emaillist.Contains(email_champion) == false) emaillist.Add(email_champion); + if (string.IsNullOrEmpty(email_champion) == false && emaillist.Contains(email_champion) == false) emaillist.Add(email_champion); if (string.IsNullOrEmpty(email_design) == false && emaillist.Contains(email_design) == false) emaillist.Add(email_design); if (string.IsNullOrEmpty(email_epanel) == false && emaillist.Contains(email_epanel) == false) emaillist.Add(email_epanel); if (string.IsNullOrEmpty(email_software) == false && emaillist.Contains(email_software) == false) emaillist.Add(email_software); @@ -1213,7 +1213,7 @@ namespace Console_SendMail public static void SendMail() { - + var timestr = DateTime.Now.ToString("yyMMddHHmmss"); //메일서버역할이 있다. try { @@ -1234,7 +1234,9 @@ namespace Console_SendMail var subject = string.Empty;// getdbdata(dar["subject"]).Trim(); var body = string.Empty;//getdbdata(dar["body"]).Trim(); var idx = -1; + var pdate = string.Empty; + while (dar.Read()) { @@ -1243,6 +1245,7 @@ namespace Console_SendMail list_bcc = getMaillist(dar["bcc"]); list_cc = getMaillist(dar["cc"]); + pdate = dar["wdate"].ToString(); subject = getdbdata(dar["subject"]).Trim(); body = getdbdata(dar["body"]).Trim(); idx = (int)dar["idx"]; @@ -1250,25 +1253,26 @@ namespace Console_SendMail dar.Close(); string sendMsg = ""; - if (list_from == "") + if (string.IsNullOrEmpty(list_from)) { sendMsg = ("보내는 주소가 없습니다"); } - else if (subject.Trim() == "") + else if (string.IsNullOrEmpty(subject.Trim())) { sendMsg = ("메일 제목이 없습니다"); } - else if (body.Trim() == "") + else if (string.IsNullOrEmpty(body.Trim())) { sendMsg = ("본문이 없습니다"); } - else if (list_to == "") + else if (string.IsNullOrEmpty(list_to.Trim())) { sendMsg = ("받는 주소가 없습니다"); } - + if (idx > 0) { + //오류메시지가 있다면 업데이트만 한다 if (string.IsNullOrWhiteSpace(sendMsg) == false) { //오류가 있다 @@ -1284,9 +1288,14 @@ namespace Console_SendMail //Console.WriteLine(string.Format("Send Complete index={0},Msg={1}", dar["idx"], sendMsg)); //ta.UpdateSendOK(sendMsg, dr.idx); var ucnt = cmd.ExecuteNonQuery(); + Console.Write($"[{timestr}]-IDX:{idx} [{pdate}] ErrorMessage Update Subject:{getdbdata(subject)} Messqage:{sendMsg}"); if (ucnt == 1) { - Console.WriteLine("send mail to" + list_to + ",subject=" + getdbdata(subject)); + Console.WriteLine($" [OK]"); + } + else + { + Console.WriteLine($" [ERR COUNT={ucnt}]"); } } catch (Exception eX) @@ -1303,6 +1312,9 @@ namespace Console_SendMail "
메일이 잘못 전송 되었다면 [chikyun.kim@amkor.co.kr] 로 문의 주시기 바랍니다" + "

"; + subject = subject.Replace("\r", "").Replace("\n", ""); + body = body.Replace("\r", "").Replace("\n", ""); + //전송을 해야 함 var mc = new System.Net.Mail.SmtpClient("10.101.5.150"); var msg = new System.Net.Mail.MailMessage @@ -1331,12 +1343,13 @@ namespace Console_SendMail if (ucnt == 1) { mc.Send(msg); - Console.WriteLine("send mail to" + list_to + ",subject=" + getdbdata(subject)); + Console.WriteLine($"[{timestr}]-IDX:{idx} [{pdate}] send mail to [" + list_to + "],subject=" + getdbdata(subject)); } } catch (Exception eX) { - Console.WriteLine("[sendmail] : " + eX.Message); + //오류가 발생하면 해당 오류메세지로 데이터를 업데이트 해준다. + Console.WriteLine($"[{timestr}]-IDX:{idx} [sendmail] : " + eX.Message); sendMsg = eX.Message; msgupdate = true; } @@ -1354,10 +1367,11 @@ namespace Console_SendMail var ucnt = cmd.ExecuteNonQuery(); } } - catch + catch(Exception ex) { //sendMsg = eX.Message; //msgupdate = true; + Console.WriteLine($"[{timestr}]-IDX:{idx} eror state update failed {ex.Message}"); } } } @@ -1368,9 +1382,9 @@ namespace Console_SendMail cmd.Dispose(); cn.Close(); } - catch + catch (Exception ex) { - + Console.WriteLine($"[{timestr}] [sendmail] {ex.Message}"); } finally {