I'm attempting to use CDO with Win7/Excel 10 and NO Outlook (Express or otherwise). Before this I tried code posted by Ron de Bruin which also triggered a "class not registered" error at the line: Set Flds = iConf.Fields
This is the latest code I've tried (posted at Paul Sadowski.com) and the same error is triggered at the line:
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
In researching this problem, I've found others that have had the same issue but I have not found a solution or even the source of the problem identified. I'm hoping that someone here can enlighten me either on how to correct it or even to let me know if it's hopeless. My suspician is that my lacking Outlook has something to do with it but I've found no evidence so maybe there's still hope to get cdo to work for me.
This is the latest code I've tried (posted at Paul Sadowski.com) and the same error is triggered at the line:
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
In researching this problem, I've found others that have had the same issue but I have not found a solution or even the source of the problem identified. I'm hoping that someone here can enlighten me either on how to correct it or even to let me know if it's hopeless. My suspician is that my lacking Outlook has something to do with it but I've found no evidence so maybe there's still hope to get cdo to work for me.
Code:
Sub Sendmail()
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" <me@my.com>"
objMessage.To = "test@paulsadowski.com"
objMessage.TextBody = "This is some sample message text.." & vbCrLf & "It was sent using SMTP authentication."
'==This section provides the configuration information for the remote SMTP server.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1 'CLASS NOT REGISTERED ERROR HERE USING 1 OR 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.frontier.com"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "jac@frontier.com"
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "shamRock1"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
End Sub