256 lines
5.8 KiB
C++
256 lines
5.8 KiB
C++
// DlgMailSender.cpp : 구현 파일입니다.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "CrashReport.h"
|
|
#include "DlgMailSender.h"
|
|
|
|
#include "ATL_NEW/include/atlmime.h"
|
|
#include "SMTPMailConnect.h"
|
|
|
|
|
|
// CDlgMailSender 대화 상자입니다.
|
|
|
|
IMPLEMENT_DYNAMIC(CDlgMailSender, CDialog)
|
|
|
|
CDlgMailSender::CDlgMailSender(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CDlgMailSender::IDD, pParent)
|
|
{
|
|
|
|
}
|
|
|
|
CDlgMailSender::~CDlgMailSender()
|
|
{
|
|
}
|
|
|
|
void CDlgMailSender::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST1, ListMailUserList_);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDlgMailSender, CDialog)
|
|
ON_EN_KILLFOCUS(IDC_EDIT1, &CDlgMailSender::OnEnKillfocusEdit1)
|
|
ON_BN_CLICKED(IDC_ADDUSER, &CDlgMailSender::OnBnClickedAdduser)
|
|
ON_BN_CLICKED(IDC_DELUSER, &CDlgMailSender::OnBnClickedDeluser)
|
|
ON_BN_CLICKED(IDC_MAILTOUSER, &CDlgMailSender::OnBnClickedMailtouser)
|
|
ON_WM_SHOWWINDOW()
|
|
ON_WM_ACTIVATE()
|
|
ON_WM_DESTROY()
|
|
ON_WM_CLOSE()
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CDlgMailSender 메시지 처리기입니다.
|
|
|
|
BOOL CDlgMailSender::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: 여기에 추가 초기화 작업을 추가합니다.
|
|
UserMailList_.clear();
|
|
GetListCulUser_ = -1;
|
|
|
|
LoadMailingData();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// 예외: OCX 속성 페이지는 FALSE를 반환해야 합니다.
|
|
}
|
|
|
|
void CDlgMailSender::OnEnKillfocusEdit1()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
GetDlgItemText(IDC_EDIT1,AddUserString_);
|
|
}
|
|
|
|
void CDlgMailSender::OnBnClickedAdduser()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
|
|
std::vector<CString>::iterator iter =
|
|
std::find(UserMailList_.begin(),UserMailList_.end(),AddUserString_);
|
|
|
|
//이미 사용자가 존재 함으로 안넣어도 됨
|
|
if(iter != UserMailList_.end())
|
|
return;
|
|
|
|
//스트링 타입중에 @이가 존재 하는지 찾는다/
|
|
int Find = AddUserString_.Find(L"@");
|
|
//최초 필터링
|
|
if(Find == -1)
|
|
return;
|
|
|
|
//2차 필터링
|
|
//해당 도메인이 아니라면 메일을 쓸수 없다!
|
|
int cokr = AddUserString_.Find(L".co.kr");
|
|
int com = AddUserString_.Find(L".com");
|
|
int net = AddUserString_.Find(L".net");
|
|
|
|
if (cokr == -1 && com == -1 && net == -1)
|
|
return;
|
|
|
|
UserMailList_.push_back(AddUserString_);
|
|
ListMailUserList_.AddString(AddUserString_);
|
|
}
|
|
|
|
void CDlgMailSender::OnBnClickedDeluser()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
int ListCursel = ListMailUserList_.GetCurSel();
|
|
|
|
if(ListCursel < 0)
|
|
return;
|
|
|
|
UserMailList_.erase(UserMailList_.begin() + ListCursel);
|
|
ListMailUserList_.DeleteString(ListCursel);
|
|
}
|
|
|
|
void CDlgMailSender::LoadMailingData()
|
|
{
|
|
FILE* pFile;
|
|
|
|
pFile = _tfopen(L"UserList.dat",L"rb");
|
|
|
|
if (!pFile)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int sizeData = static_cast<int>(UserMailList_.size());
|
|
fread(&sizeData,sizeof(int),1,pFile);
|
|
|
|
TCHAR memSave[256];
|
|
memset(memSave,0,sizeof(TCHAR)*256);
|
|
|
|
for (int index = 0 ; index < sizeData ; index++)
|
|
{
|
|
fread(memSave,sizeof(TCHAR)*256,1,pFile);
|
|
UserMailList_.push_back(memSave);
|
|
ListMailUserList_.AddString(memSave);
|
|
}
|
|
|
|
fclose(pFile);
|
|
}
|
|
|
|
void CDlgMailSender::SaveMailingData()
|
|
{
|
|
FILE* pFile;
|
|
|
|
pFile = _tfopen(L"UserList.dat",L"wb");
|
|
|
|
if (!pFile)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int sizeData = static_cast<int>(UserMailList_.size());
|
|
fwrite(&sizeData,sizeof(int),1,pFile);
|
|
|
|
TCHAR memSave[256];
|
|
memset(memSave,0,sizeof(TCHAR)*256);
|
|
|
|
for (int index = 0 ; index < sizeData ; index++)
|
|
{
|
|
wsprintf(memSave,L"%s",UserMailList_[index]);
|
|
fwrite(memSave,sizeof(TCHAR)*256,1,pFile);
|
|
}
|
|
|
|
fclose(pFile);
|
|
|
|
}
|
|
void CDlgMailSender::OnBnClickedMailtouser()
|
|
{
|
|
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
|
|
CMimeMessage msg;
|
|
msg.SetSender(L"Sensr7086@webzen.co.kr");
|
|
msg.SetSenderName(L"김민철");
|
|
|
|
for (size_t index = 0 ; index < UserMailList_.size() ; ++index)
|
|
{
|
|
msg.AddRecipient(UserMailList_[index]);
|
|
}
|
|
|
|
CString FilePath;
|
|
FilePath.Format(L"%s",L"C:\\Users\\sensr7086\\Documents\\");
|
|
|
|
CString Subject;
|
|
Subject.Format(L"%s%s",theApp.Excelfile,L"크레쉬 통계 입니다.");
|
|
msg.SetSubject(Subject);
|
|
|
|
CString FilePathFullPath;
|
|
FilePathFullPath.Format(L"%s%s",FilePath,theApp.Excelfile);
|
|
|
|
msg.AddText(L"오류 통계 파일 입니다.");
|
|
|
|
msg.AttachFile(FilePathFullPath);
|
|
|
|
CNEWSMTPMailConnect conn;
|
|
if(conn.Connect(L"rcvmail7.naver.com"))
|
|
{
|
|
conn.SendMessage(msg);
|
|
conn.Disconnect();
|
|
}
|
|
|
|
}
|
|
|
|
void CDlgMailSender::OnShowWindow(BOOL bShow, UINT nStatus)
|
|
{
|
|
CDialog::OnShowWindow(bShow, nStatus);
|
|
|
|
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
|
|
}
|
|
|
|
void CDlgMailSender::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
|
|
{
|
|
CDialog::OnActivate(nState, pWndOther, bMinimized);
|
|
|
|
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
|
|
|
|
//이것이 0이면 HIDE를 의미 한다,.
|
|
}
|
|
|
|
void CDlgMailSender::OnDestroy()
|
|
{
|
|
CDialog::OnDestroy();
|
|
|
|
// TODO: 여기에 메시지 처리기 코드를 추가합니다.
|
|
SaveMailingData();
|
|
}
|
|
|
|
void CDlgMailSender::OnClose()
|
|
{
|
|
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
|
|
|
|
CDialog::OnClose();
|
|
|
|
SaveMailingData();
|
|
}
|
|
|
|
BOOL CDlgMailSender::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
|
|
if(pMsg->message == WM_KEYDOWN)
|
|
{
|
|
switch(pMsg->wParam)
|
|
{
|
|
case VK_RETURN:
|
|
{
|
|
GetDlgItemText(IDC_EDIT1,AddUserString_);
|
|
//엔터를 치면 유저 추가와 같은 효과
|
|
OnBnClickedAdduser();
|
|
pMsg->wParam = NULL;
|
|
}
|
|
case VK_ESCAPE:
|
|
{
|
|
pMsg->wParam = NULL;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|