// MailTestCEDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MailTestCE.h"
#include "MailTestCEDlg.h"
#include "..\..\include\AdsMailCE.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CMailTestCEDlg dialog

CMailTestCEDlg::CMailTestCEDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMailTestCEDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMailTestCEDlg)
	m_sBody = _T("This is a test");
	m_sFrom = _T("UNO-2000.Mail.System@advantech.com.tw");
	m_sSMTP = _T("210.61.150.26");
	m_sSubject = _T("Mail Test");
	m_sTo = _T("Rose.Chou@Advantech.com.tw");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMailTestCEDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMailTestCEDlg)
	DDX_Text(pDX, IDC_BODY, m_sBody);
	DDX_Text(pDX, IDC_FROM, m_sFrom);
	DDX_Text(pDX, IDC_SMTP, m_sSMTP);
	DDX_Text(pDX, IDC_SUBJECT, m_sSubject);
	DDX_Text(pDX, IDC_TO, m_sTo);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMailTestCEDlg, CDialog)
	//{{AFX_MSG_MAP(CMailTestCEDlg)
	ON_BN_CLICKED(IDC_SEND, OnSend)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMailTestCEDlg message handlers

BOOL CMailTestCEDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	//AfxMessageBox(_T("Demo Progrom OnInitDialog"));
	AdsOpen();

	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CMailTestCEDlg::OnSend() 
{
	// TODO: Add your control notification handler code here
	int nRet;

	// get the update to date UI information
	UpdateData(TRUE);

	// Create a instance for send mail
	//AfxMessageBox(_T("Demo Progrom OnSend"));

	nRet = SendMail(m_sSMTP,
					m_sFrom,
					m_sTo,
					m_sSubject,
					m_sBody); 


}

BOOL CMailTestCEDlg::DestroyWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	//AfxMessageBox(_T("Demo Progrom  OnClose"));
	AdsClose();	
	
	return CDialog::DestroyWindow();
}
