===== 작업중 ===== 주문관리 폼 재 수정작업중 - 팩스 및 이메일 기록 폼 제작해야함. - 제작완료 (현재 목록등록 -> 수정버튼 작업중) ㄴ> 작업 완료후 검토하고, 회계로 넘어갈 것. - 회계전환 회계전환. 매출상세(Sales_Detail.cs) 폼 작업완료. (버튼 이벤트 작업진행중) ㄴ> 매출집계에서 상세까지 가는 도중 MDI 부모로 적용되지않는 버그 수정작업완료. 기타 추가적인 버그 잡을것. / 바로빌 세금계산서알아볼것. ===== 보류 ===== b. 마크목록 폼 작성중 1. 엑셀반출 기능 추가중 사용 작업대기중 c. 마크 반입 폼 수정중 1. 불러오기는 되나 저장 기능이 필요함. ===== 완료 ===== 1. 주문관리 팩스연동 완료 2. 전송된 팩스 확인 작업개시, 이메일 전송모듈 수정완료. 3. 주문관리에서 주문처와 목록 검색하는 폼 검색 모듈도 재수정 완료함. 4. 데이터베이스 내 이미지URL을 가져오는작업 완료 목록집계 폼 재 수정작업 완료 - 확인 및 수정 필요. ISBN 체크 프로그램 => 본프로그램에 이식중. ㄴ> 코드는 다 옮겼으나 기존 사용하던 방식과 조금 달라서 버그발생 가능성 있음. ㄴ> 버그 체크 계속 해볼것. 21-04-15 ㄴ> 21_04_20 버그 없음. 2. 마크편집 폼 수정 중 (마크 반출 test프로젝트 진행완료, 본 프로젝트에 적용중. / 저장기능활성화 작업완료) 2-1. 기존의 칸채우기에서 예상되지 못한 버그가 발생하여 칸채우기 숨김. 2-2. 008태크 재배치 => TextBox에 적용완료. 변경사항 메모장으로 넘기는 작업 완료. 2-3. 저장기능 완료. (04.14 체크해볼것 - 완료) 주문관리 작업중 (DataGridView 주문처 엔터키 입력시 검색되게끔 하는 코드작성중) - 21.04.27 완료
195 lines
6.5 KiB
C#
195 lines
6.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Mail;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WindowsFormsApp1
|
|
{
|
|
class Email
|
|
{
|
|
Helper_DB db = new Helper_DB();
|
|
public bool Send_mail(string compidx, string pur, string filePath, string sender)
|
|
{
|
|
db.DBcon();
|
|
|
|
#region Setup
|
|
|
|
// 보내는 이 : 메일ID, 메일PW, smtp주소, 포트번호
|
|
string sender_Area = "`comp_name`, `email_ID`, `email_PW`, `smtp`, `port`";
|
|
string tmp_db = db.DB_Select_Search(sender_Area, "Comp", "idx", compidx);
|
|
|
|
string[] arr_db = tmp_db.Split('|');
|
|
|
|
#endregion
|
|
|
|
MailMessage mail = new MailMessage();
|
|
MailMessage mail_by_self = new MailMessage();
|
|
|
|
// 보내는 사람 이메일
|
|
// mail.From = new MailAddress(arr_db[1]);
|
|
// mail_by_self.From = new MailAddress(arr_db[1]);
|
|
mail.From = new MailAddress("jhk132765@naver.com");
|
|
mail_by_self.From = new MailAddress("jhk132765@naver.com");
|
|
|
|
// 받는 사람 이메일
|
|
mail.To.Add(sender);
|
|
mail_by_self.To.Add(arr_db[3]);
|
|
|
|
// 메일 제목
|
|
mail.Subject = arr_db[0] + "주문분입니다.";
|
|
mail_by_self.Subject = "Send_" + arr_db[0] + "주문분입니다.";
|
|
|
|
// 메일 내용
|
|
mail.Body = arr_db[0] + "주문분입니다.";
|
|
mail_by_self.Body = "Send_" + arr_db[0] + "주문분입니다.";
|
|
|
|
// 첨부파일
|
|
System.Net.Mail.Attachment attachment;
|
|
|
|
// 첨부파일 붙이기
|
|
attachment = new System.Net.Mail.Attachment(filePath);
|
|
mail.Attachments.Add(attachment);
|
|
mail_by_self.Attachments.Add(attachment);
|
|
|
|
// SMTP 및 포트 설정
|
|
SmtpClient smtp = new SmtpClient(arr_db[3], Convert.ToInt32(arr_db[4]));
|
|
SmtpClient smtp_by_self = new SmtpClient(arr_db[3], Convert.ToInt32(arr_db[4]));
|
|
smtp.EnableSsl = true;
|
|
smtp_by_self.EnableSsl = true;
|
|
|
|
// 계정 설정
|
|
smtp.Credentials = new NetworkCredential(arr_db[1], arr_db[2]);
|
|
smtp_by_self.Credentials = new NetworkCredential(arr_db[1], arr_db[2]);
|
|
|
|
try
|
|
{
|
|
smtp.Send(mail);
|
|
smtp_by_self.Send(mail_by_self);
|
|
MessageBox.Show("메일 전송 완료");
|
|
return true;
|
|
}
|
|
catch(SmtpException e)
|
|
{
|
|
MessageBox.Show(e.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 테스트 메일 보낼때 사용. (추후 함수가 기반이 되어야함.)
|
|
/// ex. email.Send_Test_mail("관리", "jhk132765@gmail.com");
|
|
/// </summary>
|
|
/// <param name="comp_name">DB에 저장된 회사명.</param>
|
|
/// <param name="taker">받는 업체의 메일주소.</param>
|
|
public void Send_Test_mail(string compidx, string taker, string title, string content)
|
|
{
|
|
db.DBcon();
|
|
string tmpdata = db.DB_Select_Search("`email_ID`, `email_PW`, `smtp`, `port`",
|
|
"Comp", "idx", compidx);
|
|
string[] data = tmpdata.Split('|');
|
|
int port = Convert.ToInt32(data[3]);
|
|
if(port == 465) { port = 587; } // 465포트는 기술적으로 사용되지않음. 587로 대체.
|
|
|
|
MailMessage mail = new MailMessage();
|
|
|
|
// 보내는 사람 이메일
|
|
mail.From = new MailAddress(data[0]);
|
|
|
|
// 받는 사람 이메일
|
|
mail.To.Add(taker);
|
|
|
|
// 메일 제목
|
|
mail.Subject = title;
|
|
|
|
// 메일 내용
|
|
mail.Body = content;
|
|
|
|
// SMTP 및 포트 설정
|
|
SmtpClient smtp = new SmtpClient(data[2], port);
|
|
smtp.EnableSsl = true;
|
|
|
|
// 계정 설정
|
|
smtp.Credentials = new NetworkCredential(data[0], data[1]);
|
|
|
|
try
|
|
{
|
|
smtp.Send(mail);
|
|
MessageBox.Show("메일 전송 완료");
|
|
}
|
|
catch (SmtpException e)
|
|
{
|
|
MessageBox.Show(e.ToString());
|
|
}
|
|
}
|
|
}
|
|
class TestMail
|
|
{
|
|
Helper_DB db = new Helper_DB();
|
|
/// <summary>
|
|
/// 메일을 보내기 위한 함수
|
|
/// </summary>
|
|
/// <param name="sender">보내는 사람 메일</param>
|
|
/// <param name="taker">받는 사람 메일</param>
|
|
/// <param name="title">메일의 제목</param>
|
|
/// <param name="content">메일의 내용</param>
|
|
/// <param name="link">첨부파일의 경로</param>
|
|
public void Send_Mail(string sender, string taker, string title, string body, string link = "")
|
|
{
|
|
db.DBcon();
|
|
|
|
string Area = "`smtp`, `port`, `email_ID`, `email_PW`";
|
|
string db_tmp = db.DB_Select_Search(Area, "Comp", "email_ID", sender);
|
|
string[] db_data = db_tmp.Split('|'); // smtp, port, email_ID, email_PW
|
|
string smtp = db_data[0];
|
|
int port = Convert.ToInt32(db_data[1]);
|
|
string id = db_data[2];
|
|
string pw = db_data[3];
|
|
|
|
MailMessage mail = new MailMessage();
|
|
|
|
// 보내는 사람 이메일 주소
|
|
mail.From = new MailAddress(sender);
|
|
|
|
// 받는 사람 이메일 주소
|
|
mail.To.Add(taker);
|
|
|
|
// 메일 제목
|
|
mail.Subject = title;
|
|
|
|
// 메일 내용
|
|
mail.Body = body;
|
|
|
|
if(link != "") { Attach_File(mail, link); }
|
|
|
|
// 포트 설정
|
|
SmtpClient tp = new SmtpClient(smtp, port);
|
|
|
|
// SSL 설정
|
|
tp.EnableSsl = true;
|
|
|
|
// 메일 인증을 위한 id/pw (Sender 정보)
|
|
tp.Credentials = new NetworkCredential(id, pw);
|
|
try
|
|
{
|
|
tp.Send(mail);
|
|
MessageBox.Show("메일이 전송되었습니다.");
|
|
}
|
|
catch(SmtpException e)
|
|
{
|
|
MessageBox.Show(e.ToString());
|
|
}
|
|
}
|
|
public void Attach_File(MailMessage mail, string link)
|
|
{
|
|
System.Net.Mail.Attachment attachment;
|
|
attachment = new System.Net.Mail.Attachment(link);
|
|
|
|
mail.Attachments.Add(attachment);
|
|
}
|
|
}
|
|
}
|