|
-
September 1st, 2009, 10:23 AM
#1
Unable to send email via CDO
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.
-
September 1st, 2009, 10:55 AM
#2
Re: Unable to send email via CDO
CDO requires you to have a Microsoft Exchange Server in your company/network, which you interface to. It is not a stand alone technology.
-
September 1st, 2009, 11:03 AM
#3
Re: Unable to send email via CDO
Hi,
Thanks for the reply.
Can you tell me another way of sending the message without any need for servers to be installed.
Regards.
-
September 2nd, 2009, 12:56 AM
#4
Re: Unable to send email via CDO
There are more than 10 methods to send mails ! (MApi, cdoex, etc)
See MSDN samples for each one.
-
September 2nd, 2009, 10:30 AM
#5
Re: Unable to send email via CDO
CDO (and it's variants) require access to an Exchange server.
MAPI needs a working email client that supports simple MAPI
Some email clients have their own set of API's (Outlook has the outlook object model)
You can send mail by implementing your own (sending side) of an SMTP server.
You can write your own POP3 to send stuff to your SMTP server.
You can write a wrapper around a simple SMTP sending tool such as Blat (www.blat.net).
There is no "best". It all depends what you have access to and how much time you're willing to invest developping a sending feature for each
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|