AksDue 2016-03-04 08:04 采纳率: 0%
浏览 1301

MFC做一个邮件发送,好像连接服务器的时候老是报502,求指正

void CMailDlg::OnSend()
{
// TODO: Add your control notification handler code here
//更新数据
UpdateData( TRUE );
//建立CSMTP对象
CSMTP smtp("smtp.126.com",25);
//新建CMailMessage对象,并初始化
CMailMessage msg;
msg.m_sFrom = m_User;
msg.AddMultipleRecipients( m_Sendto );
msg.m_sSubject = m_Subject;
msg.m_sBody = m_Concent;
//连接SMTP服务器
if( !smtp.Connect(m_User,m_Password) )
{
MessageBox("ERROR","连接失败!",MB_OK);
AfxMessageBox( smtp.GetLastError() );
return;
}

//发信
if( !smtp.SendMessage( &msg ) )
{
    MessageBox("ERROR","发送!",MB_OK);
    AfxMessageBox( smtp.GetLastError() );
    return;
}
MessageBox("1","1,",MB_OK);
    //断开连接
if( !smtp.Disconnect() )
{
    AfxMessageBox( smtp.GetLastError() );
    return;
}
AfxMessageBox( _T( "Message Sent Successfully") );

}

void CMailDlg::OnClickList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int nItem;
///////////////
for(nItem=0;nItem<10; nItem++)
{
if(m_List.GetItemState(nItem, LVIS_SELECTED) == LVIS_SELECTED )
{
// 第i行被选中
//pop3.SetUserProperties(m_User,m_Password);
//pop3.Connect();
CMailMessage msg;
if (!pop3.GetMessage(nItem+1,&msg))
{
AfxMessageBox( pop3.GetLastError() );
return;
}
m_Body=msg.m_sBody;
}
}
UpdateData(FALSE);

*pResult = 0;

}

  • 写回答

2条回答

  • threenewbee 2016-03-05 23:43
    关注

    502是服务器出错,你的用户名密码没有错误吧,是126邮箱么?

    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧