CDO Question

Can someone give me a quick example on how to use CDO to send an email from either a macro or a button?  I'm using Outlook and Access 2007.  Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
This is an older article but it is valid:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
error_proneAuthor Commented:
I'm testing the code below to send an email through a macro.  When I run the macro I don't receive an error, but I never receive the email either.
I'm running this on a company network.  Are there certain network settings that will prevent the email from sending but won't give me an error?

Public Function SendNotesMail()

Dim objEmail As Object
 On Error Resume Next
    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = ""
    objEmail.To = ""
    objEmail.subject = "testing the subject"
    objEmail.TextBody = "testing the email body."
    'If strAttach <> "" Then objEmail.AddAttachment strAttach
    objEmail.Configuration.Fields.Item("") = 2
    objEmail.Configuration.Fields.Item("") = "something.something.exch"
    objEmail.Configuration.Fields.Item("") = 25
    'If Err.Number <> 0 Then
    'End If
    Set objEmail = Nothing

End Function
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
Here is a working example:

E-Mail to Multiple Recipients Using CDO Object
ends e-mail to multiple recipients using the CDO object (cdonts.dll)and stores the addresses in the database.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

error_proneAuthor Commented:
Says it's missing a reference to cdonts.dll.  How do I reference it?
error_proneAuthor Commented:
I downloaded and registered the dll but when I try to send an email it says "Error. Message not delivered to selected recipeints."
error_proneAuthor Commented:
Is there anything wrong with the example I posted above?
error_proneAuthor Commented:
I even put a message box at the end of the code to see if it ran all the way through. I get the message box but never the email.
error_proneAuthor Commented:
I took out the OnError line on the code I used above and am now receiving the following error:
The "SendUsing" configuration value is invalid.  How can I fix this?
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
SendUsing refers to the SMTP server that you're using. Are you absolutely sure that (a) you have a valid, configured SMTP server on the network and (b) you can send email in this fashion using the SMTP server? You'll have to ask your IT people about this, if you have any. If not, explain a little more about your network configuration - are you using Exchange for emails, for example? Are you using Outlook?

This article might help:
error_proneAuthor Commented:
Outlook 2007 and yes it's an Exchange server. Is there a way I can make sure if I'm using the right smtp server?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.