CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2006
    Posts
    28

    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.

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    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.

  3. #3
    Join Date
    Jan 2006
    Posts
    28

    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.

  4. #4
    Join Date
    Sep 2009
    Posts
    5

    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.

  5. #5
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    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
  •  





Click Here to Expand Forum to Full Width

Featured