利用VS2010实现发送邮件SMTP


C++实现发送邮件,开发环境是VS2010 MFC,QQ邮箱测试通过
资源截图
代码片段和文件信息

// Email_Demo.cpp : Defines the class behaviors for the application.
//

#include “stdafx.h“
#include “Email_Demo.h“
#include “Email_DemoDlg.h“

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CEmail_DemoApp

BEGIN_MESSAGE_MAP(CEmail_DemoApp CWinApp)
ON_COMMAND(ID_HELP &CWinApp::onhelp)
END_MESSAGE_MAP()


// CEmail_DemoApp construction

CEmail_DemoApp::CEmail_DemoApp()
{
// support Restart Manager
m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;

// TODO: add construction code here
// Place all significant initialization in InitInstance
}


// The one and only CEmail_DemoApp object

CEmail_DemoApp theApp;


// CEmail_DemoApp initialization

BOOL CEmail_DemoApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles.  Otherwise any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);

CWinApp::InitInstance();

if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}


AfxEnableControlContainer();

// Create the shell manager in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;

// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable you should remove from the following
// the specific initialization routines you do not need
// Change the registry key under which our settings are stored
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization
SetRegistryKey(_T(“Local AppWizard-Generated Applications“));

CEmail_DemoDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
}

// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}

// Since the dialog has been closed return FALSE so that we exit the
//  application rather than start the application‘s message pump.
return FALSE;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    6468608  2015-09-06 16:47  Email_DemoDebugEmail_Demo.exe

     文件   15299140  2015-09-06 16:47  Email_DemoDebugEmail_Demo.ilk

     文件   27192320  2015-09-06 16:47  Email_DemoDebugEmail_Demo.pdb

     文件      89476  2015-09-06 16:43  Email_DemoEmail_DemoEmail_Demo.aps

     文件       2615  2015-08-31 16:51  Email_DemoEmail_DemoEmail_Demo.cpp

     文件        529  2015-08-31 16:51  Email_DemoEmail_DemoEmail_Demo.h

     文件       9820  2015-08-31 16:59  Email_DemoEmail_DemoEmail_Demo.rc

     文件       6026  2015-09-01 09:59  Email_DemoEmail_DemoEmail_Demo.vcxproj

     文件       2235  2015-09-01 09:59  Email_DemoEmail_DemoEmail_Demo.vcxproj.filters

     文件        143  2015-08-31 16:51  Email_DemoEmail_DemoEmail_Demo.vcxproj.user

     文件       3578  2015-09-06 16:46  Email_DemoEmail_DemoEmail_DemoDlg.cpp

     文件        683  2015-09-01 12:50  Email_DemoEmail_DemoEmail_DemoDlg.h

     文件       4599  2015-08-31 16:51  Email_DemoEmail_DemoReadMe.txt

     文件      67777  2009-08-31 02:31  Email_DemoEmail_Demo
esEmail_Demo.ico

     文件        804  2015-08-31 16:51  Email_DemoEmail_Demo
esEmail_Demo.rc2

     文件        487  2015-08-31 16:51  Email_DemoEmail_DemoResource.h

     文件      16389  2015-09-01 13:11  Email_DemoEmail_DemoSendMail.cpp

     文件       2320  2015-09-01 12:50  Email_DemoEmail_DemoSendMail.h

     文件          0  2015-09-01 09:56  Email_DemoEmail_DemoSock.cpp

     文件          0  2015-09-01 09:56  Email_DemoEmail_DemoSock.h

     文件        212  2015-08-31 16:51  Email_DemoEmail_Demostdafx.cpp

     文件       1865  2015-08-31 16:51  Email_DemoEmail_Demostdafx.h

     文件        314  2015-08-31 16:51  Email_DemoEmail_Demo argetver.h

     文件   71454720  2015-09-06 16:47  Email_DemoEmail_Demo.sdf

     文件        897  2015-08-31 16:51  Email_DemoEmail_Demo.sln

    ..A..H.     19968  2015-09-06 16:47  Email_DemoEmail_Demo.suo

     目录          0  2015-09-01 13:11  Email_DemoEmail_Demo
es

     目录          0  2015-09-01 13:11  Email_DemoDebug

     目录          0  2015-09-06 16:48  Email_DemoEmail_Demo

     目录          0  2015-09-06 16:48  Email_Demo

............此处省略3个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)