RE: error :997 (ERROR_IO_PENDING) while trying to use CSMTPConnection
From what I think is that the previous call (before SendMessage) to
Connect() has not yet finished and hence this error occurs,
I have also tried to put this in loop:
while( GetLastError()==997)
conn.SendMessage(Message) ;
But it keeps running in this loop and sometimes it comes out of the loop
with error
ERROR_NETNAME_DELETED(The specified network name is no longer available).
"nexolite" wrote:
Hi,
I am trying to send a mail using CSMTPConnection but when I call
CSMTPConnection::SendMessage() I get the error code 977 (ERROR_IO_PENDING).
here is my code:
void SendMail()
{
::CoInitialize(NULL);
CMimeMessage Message;
Message.SetSender(L"test@test.com");
Message.SetSenderName(L"Software");
Message.AddRecipient(L"someone@gmail.com");
Message.SetSubject("test");
Message.AddText("TEST123");
Message.AttachFile(L"C:\\attch.jpeg");
CSMTPConnection conn;
if(conn.Connect(L"smtp.gmail.com"))
{
if(conn.SendMessage(Message) == TRUE)
MessageBox(L"Message sent");
else
{
DWORD Error = GetLastError();
CString err;
err.Format(L"%d",Error);
MessageBox(err);
MessageBox(L"Message sending failed");
}
conn.Disconnect();
}
else MessageBox(L"Error Connecting");
}
How can I remove this error and send the mail?