email through CDO

G

GeorgeMar

I am trying to send an email using Paul Sadowski's example.

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "(e-mail address removed)"
objMessage.To = "(e-mail address removed)"
objMessage.TextBody = "This is some sample message text."
objMessage.Send

I use my email address as Sender(From) and Recipient(TO) and I get the
error: "The transport failed to connect to the server"

All the threads I have read say that it is a simple as the codes above and
run without issues.

Anything else I need to set up?
 
G

GeorgeMar

I managed to get it to work, with the following codes below. However now the
emails are received as Junk. Any way to stop that? Each email send takes a
few seconds, any way to speed it up?

regards
george


On Error GoTo Error_Handler
Const cdoSendUsingPort = 2
Const cdoBasic = 1
Dim objCDOConfig As Object
Dim objCDOMessage As Object
Dim strSch As String


strSch = "http://schemas.microsoft.com/cdo/configuration/"
Set objCDOConfig = CreateObject("CDO.Configuration")


With objCDOConfig.Fields
.Item(strSch & "sendusing") = cdoSendUsingPort
.Item(strSch & "smtpserver") = "mail.bigpond.com"
'Only used if SMTP server requires Authentication
'.Item(strSch & "smtpauthenticate") = cdoBasic
.Item(strSch & "smtpserverport") = 25
.Item(strSch & "sendusername") = "user"
.Item(strSch & "sendpassword") = "password"
.Update
End With


Set objCDOMessage = CreateObject("CDO.Message")


With objCDOMessage
Set .Configuration = objCDOConfig
.From = "(e-mail address removed)"
.Sender = "(e-mail address removed)"
.To = "(e-mail address removed)"
.Subject = "Test Subject Line"
.TextBody = "Test Body"
'.HTMLBody = "This is not Bold But <B>This is!</B>"
.Send
End With


' Exit and cleanup
MsgBox "Email successfully sent to ..."


Exit_Here:
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing


Exit Sub


Error_Handler:
MsgBox Err & ": " & Err.Description
Resume Exit_Here
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top