By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

Trying to use CDONTS for email

P: n/a
I am hoping to be able to avoid the Outlook security problem by using
CDONTS and I tried using the code below (with appropriate change to
the address etc):

Dim oEMail As New CDONTS.EMail

oEMail.From "anyn...@anydomain.com"
oEMail.To "yourem...@yourdomain.com"
oEMail.BodyFormat = CdoBodyFormatText
oEMail.Body = "Insert some useful text here"
oEMail.Importance = CdoHigh
oEMail.AttachFile "C:\filename.txt"
oEMail.Send

There was no reference to CDO in the References so selected CDO.
Code didn't work (CDONTS.email unrecognised).

I then tried:
Sub SendEmail()
Const MailSender as String = "sender @ yourdomain.com"
Const MailRecipient as String = "recipient @ anotherdomain.com"
Const MailCCRecipient as String = "cc @ anotherdomain.com"
Const MailSubject as String = "Here's an email with an attachment"
Const MailBody as Strnig = "See the attachment"

Dim iMsg as New CDO.Message
Dim iConf as New CDO.Configuration
Dim Flds as New CDO.Fields
Dim strAttachment as String

strAttachment = "C:\somefile.txt"

With Flds
.Item(cdoSMTPServer) = "ip address or name of smtp server"
.Item(cdoSMTPServerPort) = 25 ' typically
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPConnectionTimeout) = 200
.Item(cdoSMTPAuthenticate) = cdoNTLM
End With

With iMsg
Set .Configuration = iConf
.To = MailRecipient
.CC = MailCCRecipient
.From = MailSender
.Subject = MailSubject
.TextBody = MailBody
.AddAttachment (strAttachment)
.MDNRequested = True 'return receipt on
.Send
End With

End Sub

Didn't work. Stopped at the first Dim statement. I definitely have
CDO referenced.

Anyone able to help? e.g. how do I get the CDONTS method to work
(looks simpler) or what is wrong with the CDO method?

Win XP, Access 2002.

Thanks

Jeff B.
Sep 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.