views:

358

answers:

1

CSMTPConnection is an ATL (VC++) class in atlsmtpconnection.h. Code:

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
}

Built with VS2005. Deployed in a service on a mixture of Windows 2008 and Windows 2003 servers (about 10). Works everywhere except on ONE of the windows 2003 servers, where the SendSimple method (or it might be the Connect) ALWAYS produces error 997 - Overlapped I/O operation in progress. I suppose I could just keep calling SendSimple in a loop till I don't get the error, but will that work?

A: 

Maybe you should wait for the Connected member function to return TRUE before you call SendSimple()? It sounds like you're trying to send a message before the connection to the mail server is completely established.

jeffm
The Connected property just checks if the socket handle used to communicate with the SMTP server is valid. If Connect() returns TRUE, it has already used the socket to send HELO and received a response, so the socket must be valid.
Jeremy Tinkler