+ Reply to Thread
Results 1 to 11 of 11

Sending email by CDO - server connection problem

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2007
    Posts
    10

    Sending email by CDO - server connection problem

    This is a tricky one to describe. I'm using Ron deBruin's sample code to send an email from Excel VBA, as follows (a cut-down version for the purposes of discussion here, but this is the effective bones of the matter):

    Please Login or Register  to view this content.
    The problem is that I'm writing this for a friend whose ISP is btinternet. Mine is O2 (we are in the UK for anyone who doesn't recognise these names). The above code works perfectly on my machine if I replace the smtpserver name above with my O2 one, and remove the smtpauthenticate and smtpusessl parameters even though in the properties of my email account the 'Server requires authentication' box is ticked. The smtpserver name for his system is as given on the BT website, so I'm pretty sure it's correct and valid.

    The exact code as given above fails on his machine with the error "The transport failed to connect to the server".

    I'm not sure if this is significant, but he has Outlook and I do not. My understanding of the CDO method is that it's independent of the installed mail client.

    I have tried all sorts of things, including removing the authentication and usessl parms (separately and together), disabling his anti-virus (one called Avast!), but he gets nothing but the above error or some variation of it (one of which politely asks that authentication should be activated) all of which indicate a lack of communication with the server.

    Now I guess I could rewrite it to connect to Outlook using Mr DeBruin's examples but I don't want to do that - it would confuse the user (who isn't particularly computer literate) and the whole point of this exercise is for emails to get sent quickly and silently when he hits the button to do so. Apart from that, I can't develop and test it because I don't have Outlook.

    We are both using Office 2007 and Windows 7 Home. He has Outlook 2007. I use Windows Live Mail.

    Anyone got any ideas? I'm fresh out. Could the server port be something other than 25? If so, what?

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Sending email by CDO - server connection problem

    Hi -

    Have you tried playing port # 465 or 587?

    Regards,
    event

  3. #3
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Sending email by CDO - server connection problem

    or this
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  4. #4
    Registered User
    Join Date
    09-19-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2007
    Posts
    10

    Re: Sending email by CDO - server connection problem

    Thanks for the suggestions. I have set up three new macros and will ask him to try them out.

    I gave them a go on my own machine and the ports 465 and 587 failed with the above-mentioned error (as you might expect seeing 25 is the one that works for me), but John's suggestion gave me the error

    'The "SendUsing configuration value is invalid'

    on the .Send instruction.

    Well, I'll wait and see what he gets and report back.

    Bill
    Last edited by Bill4786; 10-30-2012 at 01:56 PM.

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Sending email by CDO - server connection problem

    or
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-19-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2007
    Posts
    10

    Re: Sending email by CDO - server connection problem

    John,

    Thanks for the Outlook alternative. It might come down to this but sadly I can't test it out myself and I'm totally unfamiliar with what happens.

    Can you tell me what the user's experience of this method is, after he hits the button? Will it start up a visible instance of Outlook if it's not active already? What if it is active already? Will the sent email end up in a 'Sent Items' folder or anywhere? What's the difference between .send and .display? Will there be any warning messages or will it go silently like under CDO? I'd like to know all the little details if possible, so I can explain them to my friend if necessary.

    Should the Outlook application object created not have to be 'nothingised' (or whatever way it gets removed) at the end?

    Will he need to install the Outlook object library in Tools/References?

    Bill
    Last edited by Bill4786; 10-30-2012 at 01:44 PM.

  7. #7
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Sending email by CDO - server connection problem

    -After yr friend hits the button the email is sent if the command is
    Please Login or Register  to view this content.
    the email is sent without any warning and it can be found in Sent Items
    -If is .display (have a look into code), the email is displayed, if you want to send it just hit Send button in Outlook...
    I think the best way is to be tested it by yr friend and see if it helps ..!

  8. #8
    Registered User
    Join Date
    09-19-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2007
    Posts
    10

    Re: Sending email by CDO - server connection problem

    Hi,

    The test macros using (a) John's first suggestion (i.e. no http://schemas.microsoft.com/cdo/configuration parameters at all) (b) Port 465 and (c) Port 587 all failed. The error messages were respectively:

    (a) The "SendUsing" configuration was invalid.
    (b) The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available.
    (c) The transport failed to connect to the server.

    Looks like (b) might have some mileage as it seems to have got further than anything else in that the server might actually have recognised that something was trying to connect to it. Are there any other parms that might let this one go one stage further?

    Well, unless there are any other tweaks or suggestions, it looks like I'll have to use the Outlook method. I'm very puzzled though. CDO should work. This isn't my first project with this and it's always worked in the past.

    Regards

    Bill

  9. #9
    Registered User
    Join Date
    09-19-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2007
    Posts
    10

    Re: Sending email by CDO - server connection problem

    Hi.

    OK, I've given up on the CDO method and will go with Outlook.

    I suddenly remembered that my wife uses Outlook on her machine, so I borrowed it for some testing. I used the following code as kindly supplied above by John55:
    Please Login or Register  to view this content.
    I tried this 4 times - twice with Outlook running and changing .Send to .Display on the second go, and also twice with Outlook not running, using .Send then .Display.

    They all worked except for using .Send when Outlook was not active. The error received was "Application-defined or object-defined error" (No 287) on the .Send instruction. Is this normal? One would naturally expect it to work.

    I'd be grateful for any advice on solving this last piece of the jigsaw.

    Bill

  10. #10
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,060

    Re: Sending email by CDO - server connection problem

    hi, when Outlook is not active
    can try this trick, it works! hope it helps you!
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-19-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2007
    Posts
    10

    Re: Sending email by CDO - server connection problem

    OK, thanks.

    I'll mark this off as resolved (even though it wasn't really).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1