以下是C++的代码。smtp.dll就不提供了。
请麻烦会的朋友写一下。HINSTANCE hinstDLL=NULL;
hinstDLL=LoadLibrary("smtp.dll");
if(hinstDLL)
{
typedef int(WINAPI *pSendMail)(LPCSTR smtpserver,LPCSTR user,LPCSTR pwd,LPCSTR sender,LPCSTR receiver,LPCSTR title,LPCSTR bodys);
typedef int(WINAPI *pGetSmtpError)(LPSTR strerrmsg);
pSendMail psendmail;
pGetSmtpError pgetsmtperror;
psendmail = (pSendMail)GetProcAddress(hinstDLL,"SendMail");
pgetsmtperror = (pGetSmtpError)GetProcAddress(hinstDLL,"GetSmtpError");
char* stserver = "smtp.163.com";
char* user = "xiaoqiangzi5271";
char* pwd = "我的密码";
char* sender = "xiaoqiangzi5271@163.com";
char* receiver = "bestsanmao@qq.com";
char* title = "邮件标题";
char* body = "邮件内容";
if(psendmail(stserver,user,pwd,sender,receiver,title,body))
{
MessageBox("发送邮件成功");
}
else
{
char strerrmsg[100];
//LPSTR strerrmsg=NULL;
//CString str;
pgetsmtperror(strerrmsg);
MessageBox(strerrmsg,"邮件发送失败");
}
}
else
{
MessageBox("装载smtp.dll错误","装载错误");
}
FreeLibrary(hinstDLL);
|