邮件发送类CSMTPConnection
实现方法
CSMTPMessage testm; testm.AddMultipleRecipients(_T(" PJ Naughter < pjn@indigo.ie > , My Boss <someboss@company.com> ; Joe <joe@ms.com>")); //Create the SMTP connection CSMTPConnection smtp; //Connect to the server if (!smtp.Connect(_T("127.0.0.1"))) { CString sResponse = smtp.GetLastCommandResponse(); TRACE(_T("Failed to connect to SMTP server\n")); return FALSE; } //Create a test message CSMTPMessage m; CSMTPAddress From(_T("Some Person"), _T("someone@yourdomain.com")); //Change these values to your settings m.m_From = From; CSMTPAddress To(_T("Another Person"), _T("someone2@yourdomain.com")); //Change these values to your settings m.AddRecipient(To); m.m_sSubject = _T("Test Message"); m.AddBody(_T("The CSMTPConnection classes allows\r\n.\r\n.you to send SMTP messages from MFC code")); //Testing Reply To support //m.m_ReplyTo = CSMTPAddress(_T("Another PJ"), _T("pj.naughter@softech-telecom.com")); //Testing attachment support CSMTPAttachment attachment; attachment.Attach(_T("C:\\AUTOEXEC.BAT")); m.AddAttachment(&attachment); //Sent the message if (!smtp.SendMessage(m)) { CString sResponse = smtp.GetLastCommandResponse(); TRACE(_T("Failed to send the SMTP message\n")); return FALSE; } //Disconnect from the server smtp.Disconnect();
注:转载文章需注明来源:VCer.net 文章地址:http://vcer.net/2012.html
如果你觉得VCer.net不错,而且你愿意为VCer.net捐赠一元钱,那么点击后面的捐赠按钮吧:)
我得意,我用他的代码;
我自豪,他用我的代码!
void main() { printf("hello, vcer!"); }
A B C D E
SMTP邮件服务器与密码怎么添加上去..
yerong 于 2008-03-13 09:32:40.0 编辑 [回复该贴]