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.
error_proneAsked:
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:

http://support.microsoft.com/kb/161833
0

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 = "me.me@mydomain.com"
    objEmail.To = "me.me@mydomain.com"
    objEmail.subject = "testing the subject"
    objEmail.TextBody = "testing the email body."
    'If strAttach <> "" Then objEmail.AddAttachment strAttach
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "something.something.exch"
    objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send
    'If Err.Number <> 0 Then
 
    'Else
   
    'End If
    Set objEmail = Nothing

End Function
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPCommented:
Here is a working example:

http://www.candace-tripp.net/download/emailcdo2k.zip

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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

error_proneAuthor Commented:
Says it's missing a reference to cdonts.dll.  How do I reference it?
0
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."
0
error_proneAuthor Commented:
Is there anything wrong with the example I posted above?
0
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.
0
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?
0
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:
http://technet.microsoft.com/en-us/library/ee176585.aspx
0
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?
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.