+ Reply to Thread
Results 1 to 2 of 2

Sending mail with CDO through a remote SMTP server - problem with Reply To address

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

    Sending mail with CDO through a remote SMTP server - problem with Reply To address

    I want to send emails from VBA using the CDO functionality. I have used the method described by Ron De Bruin successfully in the past but only using my local SMTP server. I now need to do the same with a remote server, such as Gmail.

    I found something potentially suitable in the ever-informative Ron de Bruin's downloaded examples (http://www.rondebruin.nl/files/CDO_Example_Code.zip) which handily gives sample code for using with Gmail. This works, and emails do get sent and are received. However, the sticking point for me is what goes into the From (or reply-to) field in the delivered email. The comments where he says you can use the .ReplyTo parameter before the .Send seem appropriate. Here they are:

    ' Note: The reply address is not working if you use this Gmail example
    ' It will use your Gmail address automatic. But you can add this line
    ' to change the reply address .ReplyTo = "

    Sorry Ron, this doesn't work (at least for me). Here's my simplified and anonymousised code, which is virtually identical to RdB's code except I had to user port 465:
    Code:

    Please Login or Register  to view this content.
    The resulting email has the name given in the .From parameter ("replytoname" here, and can be Mickey Mouse or any text string you want) but the associated email address is the Gmail address given in the CDO parm 'sendusername'. i.e. "[email protected]" is totally ignored everywhere. Same if it's set in the CDO parm "senduserreplyemailaddress" (another potential solution to this that doesn't work). A 'Reply' to this email will go to the Gmail address, not to the sender's address. NOT what I want!

    I've googled this five ways from Sunday with no solution found and I'm out of ideas. Is there something in my PC's setup that might be preventing this working? I have Windows 7 Home and Office 2007.

    I use Windows Live for my normal email client (Outlook is not installed), but I'm writing this application for a friend who only uses Hotmail and also has no Outlook. He runs W7 and Office 2010. He may or may not have Windows Live installed but in any case he does not use it and it will have no accounts defined and so cannot use a local SMTP server. I'm using my own Gmail account (which I only use on my iPad, and rarely there) as the remote server for all this but if it doesn't work for me is it ever going to work for him? I need that return address to be his Hotmail address as he *will* be expecting replies. In this testing phase I'm using my own O2 account in its place, not that it matters a jot what that address is as it's ignored anyway.

    Help. Please. I posted this on another well-known Excel help forum but it received no responses at all. I'm hoping that this post might reach a different set of experts who will be able to shed the light. Or at least make some suggestions. Anyone know if Mr De Bruin is receptive to random questions directly from strangers?

    Regards,

    Bill

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

    Re: Sending mail with CDO through a remote SMTP server - problem with Reply To address

    OK. Fixed it. I have to admit to a certain amount of redness in the facial area.

    I didn't go far enough in the testing of the received email. The displayed heading in my Windows Mail Inbox of was of the form "replytoname ([email protected])" and in my innocence I believed that email address to be the Reply To address. I never actually tried to do a reply to it. When I did that today, more out of frustration than serious testing, lo and behold it provided the correct email address in the To field. i.e. [email protected] from my code above.

    Case closed.

+ 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