a. 팩스전송 완료. b. 마크목록 폼 작성중 1. 엑셀반출 기능 추가중 사용 작업중 2. 마크편집 폼 수정 중 (마크 반출 test프로젝트 진행완료, 본 프로젝트에 적용중. / 저장기능활성화 작업완료) 2-1. 기존의 칸채우기에서 예상되지 못한 버그가 발생하여 칸채우기 숨김. 2-2. 008태크 재배치 => TextBox에 적용완료. 변경사항 메모장으로 넘기는 작업 진행해야함. 2-3. 현재 TODO : 저장기능 * ISBN 체크 프로그램 - ★작업완료★ a. 현재 마크팀 배포완료. - 추후 수정사항발생시 수정할 것. TODOLIST 1. 주문관리 팩스연동 완료 2. 전송된 팩스 확인 작업개시, 이메일 전송모듈 수정할것.
184 lines
6.0 KiB
C#
184 lines
6.0 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 void Send_mail(string compidx, string pur, string filePath)
|
|
{
|
|
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('|');
|
|
|
|
// 받는 이 : 메일
|
|
string taker_Area = "`email`";
|
|
tmp_db = db.DB_Select_Search(taker_Area, "Purchase", "sangho", pur);
|
|
|
|
string[] arr_pur = tmp_db.Split('|');
|
|
#endregion
|
|
|
|
MailMessage mail = new MailMessage();
|
|
|
|
// 보내는 사람 이메일
|
|
mail.From = new MailAddress("jhk132765@naver.com");
|
|
|
|
// 받는 사람 이메일
|
|
mail.To.Add("jhk132765@gmail.com");
|
|
|
|
// 메일 제목
|
|
mail.Subject = "메일 제목"; // arr_db[0] + "주문분입니다.";
|
|
|
|
// 메일 내용
|
|
mail.Body = "메일 내용"; // arr_db[0] + "주문분입니다.";
|
|
|
|
// 첨부파일
|
|
System.Net.Mail.Attachment attachment;
|
|
|
|
// 첨부파일 붙이기
|
|
attachment = new System.Net.Mail.Attachment(filePath);
|
|
mail.Attachments.Add(attachment);
|
|
|
|
// SMTP 및 포트 설정
|
|
SmtpClient smtp = new SmtpClient("smtp.naver.com", 587); // (arr_db[3], Convert.Int32(arr_db[4]);
|
|
smtp.EnableSsl = true;
|
|
|
|
// 계정 설정
|
|
smtp.Credentials = new NetworkCredential("jhk132765@naver.com", "cjaeks3356!"); // (arr_db[1], arr_db[2]);
|
|
|
|
try
|
|
{
|
|
smtp.Send(mail);
|
|
MessageBox.Show("메일 전송 완료");
|
|
}
|
|
catch(SmtpException e)
|
|
{
|
|
MessageBox.Show(e.ToString());
|
|
}
|
|
}
|
|
/// <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);
|
|
}
|
|
}
|
|
}
|