CSMTPConnection 是 atlsmtpconnection.h 中的 ATL (VC++) 类。代码:
static _TCHAR mailserver[ 256 ];
static _TCHAR mailsender[ 256 ];
static _TCHAR mailrecips[ 256 ];
static _TCHAR subject[ 256 ];
static _TCHAR msg[ 256 ];
static DWORD mailtimeout=10000;
static CSMTPConnection con;
...
if (con.Connect( mailserver, mailtimeout )){
if (con.SendSimple( mailrecips, mailsender, subject, msg)) {
// it worked
} else {
// it failed
}
} else {
// it failed
}
用VS2005构建。部署在混合了 Windows 2008 和 Windows 2003 服务器(大约 10 个)上的服务中。可以在任何地方工作,除了其中一个 Windows 2003 服务器,其中 SendSimple 方法(或者它可能是 Connect)总是产生错误 997 - Overlapped I/O operation in progress。我想我可以一直在循环中调用 SendSimple 直到我没有收到错误,但这会起作用吗?