Hi Everyone,

I wrote some lines of code in order to send email via CDO. But it always return an error but if send the email through outlook it works without any problem. Both are using the same SMTP server.

Here is the code: -

IMessagePtr ipMsg;
ipMsg.CreateInstance( __uuidof(Message) );


IConfigurationPtr ipConf;
ipConf.CreateInstance( __uuidof(Configuration) );

_bstr_t smtpServer = "smtp.dsl.pipex.com";
_bstr_t accountName = "My Name";
_bstr_t userName = "[email protected]";
_bstr_t password = "test123";

ipConf->Fields->GetItem(cdoSendUsingMethod)->Value = _variant_t((long)cdoSendUsingPort);
ipConf->Fields->GetItem(cdoSMTPServer)->Value = _variant_t(smtpServer);
ipConf->Fields->GetItem(cdoSMTPServerPort)->Value = _variant_t((long)25);
ipConf->Fields->GetItem(cdoSMTPAccountName)->Value = _variant_t(accountName);
ipConf->Fields->GetItem(cdoSMTPAuthenticate)->Value = _variant_t((long)cdoBasic);
ipConf->Fields->GetItem(cdoSendUserName)->Value = _variant_t(userName);
ipConf->Fields->GetItem(cdoSendPassword)->Value = _variant_t(password);
ipConf->Fields->GetItem(cdoSMTPUseSSL)->Value = _variant_t(VARIANT_FALSE);
ipConf->Fields->Update();

ipMsg->Configuration = ipConf;
ipMsg->From = "[email protected]";
ipMsg->To = "[email protected]";
ipMsg->Subject = "test mail";

ipMsg->TextBody = "Hello World!!!!!!!!!";

ipMsg->Send();


The send method always generates this error.

"The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available"


Thanks in advance.

Regards.