CDO send mail problem

P

Piotr

Hi I have strange problem, I have been using CDO VBA script from Ron de
Bruin site successfull for a long time. Now im trying to use it on the
other computer and I have strange problem:

On line: iConf.Load -1 ' CDO Source Defaults im reciving following
error: Object variable or With block not set.
????????????

regards
Peter

Sub Mail_Small_Text_CDO()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
' Dim Flds As Variant



Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")



iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds

..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"Fill in your SMTP server here"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
.Update
End With



strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"



With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.From = """Ron"" <[email protected]>"
.Subject = "Important message"
.TextBody = strbody
.Send
End With



Set iMsg = Nothing
Set iConf = Nothing
End Sub
 
R

Ruskin Hardie

You are using this on another computer, which implies, that CDO is not
installed...

The error, is because you are trying to call a property or method of the
CDO.Configuration object, but that object is not set. After the line;
Set iConf = CreateObject("CDO.Configuration")
You may want to put a message, saying something like;
If iConf Is Nothing Then MsgBox "OH DEAR!!!"

That will confirm if the object can be created. Another thing you could
check, is open up your registry and check the HKEY_CLASS_ROOT section, to
see if there is CDO.Message and CDO.Configuration key in there (there will
be heaps of entries, but it's all in alphabetical order).
 
P

Piotr

I have found CDO.dll fles in Windows folder, I have also checked
HKEY_CLASS_ROOT I have found there CDO.Message and CDO.Configuration ?
So its look like It is installed...
 
R

Ron de Bruin

Hi

Note: the examples on my site use CDO for windows 2000
See the MSDN site for more information
 
P

Piotr

I got the answer !
Ron your code works fine on my XP but my bloody Kaspersky Antivirus was
keep on blocking macro from executing.
 

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

Top