資源簡介
可運(yùn)行,發(fā)送端可發(fā)送帶附件的郵件,附件大小只測試過5M的。接收端顯示郵件編號(hào),單擊可顯示郵件內(nèi)容,并添加了黑名單功能,由于是在虛擬機(jī)上寫的,黑名單文件放置在C盤,又需要的可以自己修改。接收的郵件沒有將報(bào)文頭和正文、附件分開,附件也沒有base64解碼,有需要的自己添加功能。由于是為了應(yīng)對(duì)課設(shè),所以也沒講究太多,出錯(cuò)的地方還請(qǐng)大家指正。

代碼片段和文件信息
//?POP3.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“SMTP.h“
#include?“POP3.h“
#include?“SMTPDlg.h“
#include
#include?
#include
#include
#pragma?comment(lib“shlwapi.lib“)?
#pragma?comment(?lib“ws2_32.lib“?)?
#define?WSVERS MAKEWORD(2?0)
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
char?base64[]?=?“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/“;
/////////////////////////////////////////////////////////////////////////////
//?POP3?dialog
int?count1;
int?connection;
POP3::POP3(CWnd*?pParent?/*=NULL*/)
:?CDialog(POP3::IDD?pParent)
{
//{{AFX_DATA_INIT(POP3)
m_user?=?_T(“766936007@qq.com“);
m_pwd?=?_T(“qvsqwjssuojibbii“);
m_paper?=?_T(““);
m_mailList?=?_T(““);
m_sstate?=?_T(““);
m_black?=?_T(““);
m_set?=?_T(““);
m_blackAdd?=?_T(““);
//}}AFX_DATA_INIT
}
void?POP3::DoDataExchange(CDataExchange*?pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(POP3)
DDX_Control(pDX?IDC_COMBO1?m_blackBox);
DDX_Control(pDX?IDC_LIST2?m_state);
DDX_Control(pDX?IDC_LIST1?m_mailBOX);
DDX_Text(pDX?IDC_EDIT1?m_user);
DDX_Text(pDX?IDC_EDIT2?m_pwd);
DDX_Text(pDX?IDC_EDIT3?m_paper);
DDX_LBString(pDX?IDC_LIST1?m_mailList);
DDX_LBString(pDX?IDC_LIST2?m_sstate);
DDX_CBString(pDX?IDC_COMBO1?m_black);
DDX_Text(pDX?IDC_EDIT4?m_set);
DDX_Text(pDX?IDC_EDIT5?m_blackAdd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(POP3?CDialog)
//{{AFX_MSG_MAP(POP3)
ON_LBN_SELCHANGE(IDC_LIST1?OnSelchangeList1)
ON_BN_CLICKED(IDC_BUTTON3?OnButton3)
ON_BN_CLICKED(IDC_BUTTON5?OnsetBlack)
ON_BN_CLICKED(IDC_BUTTON1?Onadd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?POP3?message?handlers
CString?itoc(int?i)
{
char?p[100];
itoa(ip10);
CString?q(p);
return?q;
}
void?POP3::OnOK()?
{
//?TODO:?Add?extra?validation?here
m_mailBOX.ResetContent();
count1=0;
passwork();
char?rec2[1025];
CString?se;
se=“stat\r\n“;
SendMsg(connection(LPSTR)(LPCTSTR)se);?//獲取列表
int?len=recv(connectionrec210240);
rec2[len]=0;
CString?mes(rec2);
strncpy(rec2rec23);
// MessageBox(“OK“mes);
rec2[3]=0;
if(strcmp(rec2“+OK“)!=0)
{
closesocket(connection);
WSACleanup();
m_state.InsertString(count1++“獲取郵件數(shù)失敗!“);
return;
}
else{
m_state.InsertString(count1++“獲取郵件數(shù)成功!“);
}
int?flag=mes.Find(“?“);
CString?temp=mes.Mid(flag+1);
flag=temp.Find(“?“);
temp=temp.Left(flag);
flag=atoi(temp);
closesocket(connection);
WSACleanup();
for(int?i=1;i<=flag;i++)
{
m_mailBOX.AddString(itoc(i));
}
}
void?POP3::OnCancel()?
{
//?TODO:?Add?extra?cleanup?here
CSMTPDlg?b;
CDialog::OnCancel();
b.DoModal();
}
void?POP3::passwork()
{
UpdateData(true);
count1=0;
m_state.ResetContent();
CString?server=“pop.“;
int?lo
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????3543??2015-12-06?22:48??ReadMe.txt
?????文件???????1371??2015-12-07?21:22??resource.h
?????文件??????37656??2015-12-07?22:54??SMTP.APS
?????文件??????82944??2015-12-08?09:25??SMTP.ncb
?????文件???????1620??2015-12-08?02:02??SMTP.plg
?????文件???????7663??2015-12-07?22:54??SMTP.rc
?????文件???????2546??2015-12-08?09:16??SMTP.clw
?????文件???????2035??2015-12-06?22:48??SMTP.cpp
?????文件???????4244??2015-12-08?02:01??SMTP.dsp
?????文件????????516??2015-12-06?22:48??SMTP.dsw
?????文件???????1300??2015-12-06?23:10??SMTP.h
?????文件??????54784??2015-12-08?09:25??SMTP.opt
?????文件??????16815??2015-12-08?02:01??SMTPDlg.cpp
?????文件???????1749??2015-12-07?13:05??SMTPDlg.h
?????文件????????206??2015-12-06?22:48??StdAfx.cpp
?????文件???????1054??2015-12-06?22:48??StdAfx.h
?????文件???????7945??2015-12-08?02:01??POP3.cpp
?????文件???????1662??2015-12-07?22:42??POP3.h
?????文件??????55439??2015-12-08?02:02??Debug\POP3.obj
?????文件??????????0??2015-12-08?02:02??Debug\POP3.sbr
?????文件????3359744??2015-12-08?02:02??Debug\SMTP.bsc
?????文件?????139336??2015-12-08?02:02??Debug\SMTP.exe
?????文件?????299892??2015-12-08?02:02??Debug\SMTP.ilk
?????文件??????15215??2015-12-08?00:26??Debug\SMTP.obj
?????文件????7000144??2015-12-08?00:26??Debug\SMTP.pch
?????文件?????500736??2015-12-08?02:02??Debug\SMTP.pdb
?????文件???????3588??2015-12-07?22:54??Debug\SMTP.res
?????文件??????????0??2015-12-08?00:26??Debug\SMTP.sbr
?????文件??????78310??2015-12-08?02:02??Debug\SMTPDlg.obj
?????文件??????????0??2015-12-08?02:02??Debug\SMTPDlg.sbr
............此處省略8個(gè)文件信息
- 上一篇:MFC換膚非常方便
- 下一篇:直線、圓、橢圓等圖形的繪制
評(píng)論
共有 條評(píng)論