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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog