Results 1 to 14 of 14
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Sending emails with VBA CDO


    Does anyone happen to know if Microsoft has any plans to drop support for "Microsoft CDO for Windows 2000 Library", as currently found in Windows 10 64bit systems via the normal VBA references?
    Thanks,
    Bill

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    Not that I'm aware of. However, there is no longer any need to use the library when sending email using CDO. The functionality has been built into standard Access libraries since at least A2007.
    I use CDO for all email from Access and have never used that library
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    has been built into standard Access libraries since at least A2007
    I would infer from that then, that Access itself has an implied dependency and were Windows to suddenly drop support for CDO functionality that Access itself would cease to be downward compatible. That happened with Microsoft PhotoDraw with Windows 10, but that app was never mainstream as is Access. I will give it a go.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    Sorry but I don't understand the point you are making. Support for CDO is built in to one of the standard Access reference libraries. It is therefore likely to remain available for the foreseeable future.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    My first attempt to use CDO has failed. First my code and the error I get with that.

    Code:
    Option Compare Database
    Option Explicit
    Public Sub SendSimpleCDOMail()
    
        Dim mail    As CDO.MESSAGE
        Dim config  As CDO.Configuration
        
        Set mail = CreateObject("CDO.Message")
        Set config = CreateObject("CDO.Configuration")
        
        config.Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
        config.Fields(cdoSMTPServer).Value = "smtp.googlemail.com"
        config.Fields(cdoSMTPAuthenticate).Value = cdoNTLM
        config.Fields(cdoSendUserName).Value = "wcsReno@gmail.com"
        config.Fields(cdoSendPassword).Value = "#Logjam3538"
        config.Fields(cdoSMTPServerPort).Value = 25                 '465
        config.Fields(cdoSMTPUseSSL).Value = True
        config.Fields.Update
        
        Set mail.Configuration = config
        
        With mail
            .To = "graeaglebill@gmail.com"
            .From = "wcsReno@gmail.com"
            .Subject = "First email with CDO"
            .TextBody = "This is the body of the first plain text email with CDO."
            
            '.AddAttachment "C:\path\to\a\file.dat"
            
            .Send
        End With
        
        Set config = Nothing
        Set mail = Nothing
        
    End Sub
    The above code gets "this" error:
    Click image for larger version. 

Name:	000.jpg 
Views:	21 
Size:	21.2 KB 
ID:	45178

    Then, I downloaded Colin's tester and had errors with it as well:
    Click image for larger version. 

Name:	001.jpg 
Views:	23 
Size:	170.6 KB 
ID:	45179

    I've tried "SMTP.GoogleMail.Com" and "SMTP.Gmail.Com" plus ports 25 and 465. The latter is what Thunderbird uses. Also, Thunderbird gmail settings uses SLL for security. At gmail, I've allowed "less secure apps" to access my gmail account.

    What else might I try?
    Bill

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    Please click the Help button and read the help file that accompanies my CDO app. It explains what all the error codes mean so you can fix them.
    Page 4 of the Help file deals with GMail security. There are two methods of achieving the required security. I strongly recommend using the SetAppPassword approach

    Also remove the quotes in the EMail Server box
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Click image for larger version. 

Name:	003.jpg 
Views:	24 
Size:	3.1 KB 
ID:	45180

    Ah yes, the example threw me off a bit. The test worked as desired after I removed the quotes and reverted back to the 465 port address.
    Click image for larger version. 

Name:	002.jpg 
Views:	25 
Size:	63.0 KB 
ID:	45181

    I'll look into the gmail SetAppPassword in the AM.


    EDIT: I made the same changes to my code plus set the SMTPAuthenticate to use SLL and it executed just like Colin's test did.
    Last edited by GraeagleBill; 05-07-2021 at 11:35 PM.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    Glad you got it working.
    Sorry about the quotes. Its been like that for over 8 years without anyone commenting. I'll alter it.
    I think you meant SSL.
    Using SetAppPassword with GMail works well for me
    Last edited by isladogs; 05-08-2021 at 06:09 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I think you meant SSL.
    Yes. (it was late when I typed the edit, so the "sand-man" had his way with me )

    BTW, for simple plain text, it's easy to see how a simple text box or memo control can be used to create the body of an email, but what about HTML where one might want to embed an image. What type of Access control comes into play in those cases?

    EDIT: I did run your tester, but the banner did not display when the email arrived. The png banner file is in the app's directory, so that's not the problem.

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    Look at the TestHTMLEmail procedure in frmStart to see how I add images to HTML mail.

    However, although you can use inline images in HTML emails, these days many email apps block such images by default e.g. Outlook.
    Several other apps won't even allow you the option of displaying them e.g. Windows Mail, GMail. This is what happened to you.
    Where images are blocked you may see a small red X or nothing at all.

    As a result, I suggest you don't use inline images. Just attach any images to the email
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thunderbird doesn't have those restrictions. I send and receive emails daily with embedded images, but yes Windows email and Outlook block them. With perhaps one of the apps, where I'd like to switch to using CDO, the preponderance won't involve images and if an unforeseen situation arises I'll just do as you suggest and send the images as attachments.

    Did you essentially create your own email client with a CDO backbone?

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    Quote Originally Posted by GraeagleBill View Post
    Did you essentially create your own email client with a CDO backbone?
    Many of my commercial apps include a CDO email feature. That's not the same as a full email client app
    This can be used by clients to send bulk emails e.g. to all parents/carers of school students or to send email to customer support - as in the screenshot

    Click image for larger version. 

Name:	Capture.PNG 
Views:	16 
Size:	36.6 KB 
ID:	45184

    My tester app is based on the form provided for clients to setup the feature for their own environment

    NOTE: One important point. Access does not keep a copy of emails it sends using CDO.
    If you need to keep the mail for future reference, send a copy to yourself. I build that option into my apps
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  13. #13
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks with all your help with CDO. I can study your tester code regarding HTML as I venture more into adopting CDO into a couple of my apps. I won't get to do anymore for a couple of days, but I think the OP is clearly answered.
    Thanks again,
    Bill

  14. #14
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,946
    You're welcome
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automated sending of emails
    By bobsg in forum Programming
    Replies: 4
    Last Post: 12-21-2019, 10:11 AM
  2. sending emails using VBA
    By StuartR in forum Access
    Replies: 4
    Last Post: 02-19-2018, 04:56 AM
  3. Sending emails using Office 365
    By aytee111 in forum Programming
    Replies: 4
    Last Post: 11-17-2015, 09:14 AM
  4. Sending emails without interruptions
    By George in forum Access
    Replies: 14
    Last Post: 03-13-2015, 11:15 PM
  5. Sending Emails and VBA coding
    By lucy1216 in forum Programming
    Replies: 4
    Last Post: 05-20-2013, 05:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums