Sending mail from Excel with CDO

Hi all

I update my CDO page today.
Code is working now in Excel 97-2007 or 2000-2007.
http://www.rondebruin.nl/cdo.htm

If you have problems let me know.

Ron de Bruin
http://www.rondebruin.nl/tips.htm

Update:

I can’t post comments to this blog because of the new spam filter on this blog that’s why i do it this way.

I add a GMail example to the example workbook on my CDO page today.
Let me know if it is working for you.

15 Comments

  1. doco:

    [quote]
    Run-time error '-2147220960(80040220)':
    The "SendUsing" configuration value is invalid
    [/quote]

  2. najeem:

    got the same error......
    'the sendusing configuration value is invalid', though i have outlook configured and runningin my pc..

  3. Ron de Bruin:

    Please read the information on my site
    *****************************************

    It is possible that you get a Send error when you use one of the examples.
    AFAIK : This will happen if you haven't setup an account in Outlook Express or Windows Mail.
    In that case the system doesn't know the name of your SMTP server.
    If this happens you can use the commented green lines in each example.
    Don't forget to fill in the SMTP server name in each code sample where
    it says "Fill in your SMTP server here"

  4. doco:

    Using Outlook, not express

  5. doco:

    Using Outlook, not express...

  6. Ron de Bruin:

    Hi Doco

    >Using Outlook, not express...
    Then use the commented code and fill in your SMTP server

  7. sam:

    I am using CDO_Mail_Small_Text code in your workbook
    I have filled up sendusing as 2, Smtp server as "smtp.gmail.com" and port as 465
    It gives me an error Run-time error '-2147220973(8004123)'
    "The Transport failed to connect to server"

    Regards
    Sam

  8. Srinivas:

    Hi ,

    I am using CDO_Mail_Small_Text code in your workbook
    I have filled up sendusing as 2, Smtp server as "smtp.gmail.com"
    "The Transport failed to connect to server"
    Please let me know what to do
    Regards
    Srinivas

  9. sam:

    Ron,
    You need to add the below two lines as well.... else it gives the error I mentioned earlier

    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xyz@abc.com"
    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "abcd"

    Regards
    Sam

  10. Johnny:

    I needed to add this line in order to send via gmail SMTP:
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

    I hope this helps others :)

  11. David Jenkins:

    Hi RondeBruin

    Experts exchange pointed me in your direction. Most appreciated. I uncommented the "iconf.load -1 ... end with" area, filled in my SMT server (Put in quotes). When I run it, I get a multitude of errors - the latest is

    Run-time error '-2147220978(8004020e)':
    Automation error Cannot modify or delete an object that was added usig the COM+ Admin SDK

    When I comment out the code previously commented out, I get the following:

    Run-time error '-2147220960(80040220)':
    Automation error.

    I turned off norton - no improvement

    Any help you have would be greatly appreciated.

  12. Ron de Bruin:

    If it is at work ask your IT department if they block it

  13. stapuff:

    Ron -

    First of all - your code and suggestions have help me a lot. I am trying to use your code to send out an HTML Web Page NewsLetter. The email get's created and the html file get's attached but the links no longer work. I have used a sample mailing list program using the same port, SMTP, etc and the web page links work.

    Is there something other than the following that will resolve this?
    Or file on your computer
    .CreateMHTMLBody "file://C:/test.htm"

    Thanks,

    Stapuff

  14. stapuff:

    BTW - I am using Yahoo.

    In addition for others - when using Yahoo you need to add the following to Ron's code:
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpport") = 465
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

    Thanks again,

    Stapuff

  15. Ron de Bruin:

    Hi

    There is a note about the Port number in the example workbook with the code

    'If you get this error : The transport failed to connect to the server
    'then try to change the SMTP port from 25 to 465

Leave a comment