⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgsend.cpp

📁 我要下载源代码我要源代码我要下载代码我要下载源代码
💻 CPP
字号:
// DlgSend.cpp : implementation file
//

#include "stdafx.h"
#include "SendMail.h"
#include "DlgSend.h"
#include "SMTP.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgSend dialog


CDlgSend::CDlgSend(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgSend::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgSend)
	m_strContent = _T("");
	m_strFrom = _T("");
	m_strServer = _T("");
	m_strSubject = _T("");
	m_strTo = _T("");
	//}}AFX_DATA_INIT
}


void CDlgSend::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgSend)
	DDX_Text(pDX, IDC_EDIT_CONTENT, m_strContent);
	DDX_Text(pDX, IDC_EDIT_FROM, m_strFrom);
	DDX_Text(pDX, IDC_EDIT_SERVER, m_strServer);
	DDX_Text(pDX, IDC_EDIT_SUBJECT, m_strSubject);
	DDX_Text(pDX, IDC_EDIT_TO, m_strTo);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgSend, CDialog)
	//{{AFX_MSG_MAP(CDlgSend)
	ON_BN_CLICKED(ID_SEND, OnSend)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgSend message handlers

void CDlgSend::OnSend() 
{
	// TODO: Add your control notification handler code here
	UpdateData( TRUE );
	CSMTP smtp( m_strServer );
	CMailMessage msg;
	msg.m_sFrom = m_strFrom;
	msg.AddMultipleRecipients( m_strTo );
	msg.m_sSubject = m_strSubject;
	msg.m_sBody = m_strContent;
	if( !smtp.Connect() )
	{
		AfxMessageBox( smtp.GetLastError() );
		return;
	}
	if( !smtp.SendMessage( &msg ) )
	{
		AfxMessageBox( smtp.GetLastError() );
		return;
	}
	if( !smtp.Disconnect() )
	{
		AfxMessageBox( smtp.GetLastError() );
		return;
	}
	AfxMessageBox( _T( "Message Sent Successfully") );
	m_strTo = "";
	m_strSubject = "";
	m_strContent = "";
	UpdateData( FALSE );
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -