View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ingars82 ingars82 is offline
external usenet poster
 
Posts: 1
Default Run-time error 2147220960(80040220) mail with outlook

I have problems to send message from Microsoft Excel 2003, Microsoft Windows 2000 OS.
I use the code with CDO
method to send mail without using any e-mail program (Microsoft Outlook 2003,
Outlook Express). This is the function I use.

Sub Message()
' This example use late binding, you don't have to set a reference
' You must be online when you run the sub
Dim iMsg As Object
Dim iConf As Object
Dim cell As Range
Dim Flds As Variant

Application.ScreenUpdating = False

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") = "my exchange server name"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

For Each cell In Sheets("Sheet1").Columns("B").Cells.SpecialCells(x lCellTypeConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Value Like "*@*" And cell.Offset(0, 1).Value = "yes" Then
Set iMsg = CreateObject("CDO.Message")
With iMsg
Set .Configuration = iConf
.To = cell.Value
.From = """Ron"" "
.Subject = "Reminder"
.TextBody = "Dear " & cell.Offset(0, -1).Value & vbNewLine & vbNewLine & _
"Please contact us to discuss bringing your account up to date"
.Send
End With
Set iMsg = Nothing
End If
End If
Next cell
Set iConf = Nothing
Application.ScreenUpdating = True
End Sub

I get error message like this
Run-time error '-2147221164(80040154)':
Class not registered

Yellow mark is on ".Send" (after .TextBody and before End With)

When I add reference, I add the following COM's
Microsoft CDO for Exchange 2000 Library
Microsoft CDO for NTS 1.2 Library
and default references

I don't have any "Microsoft CDO windows 2000 Library" COM (maybe I have to change something in code).

If someone knows about my problem, please write back.


"jstrater" rakstîja:

I'm having the same problem, although in a different environment (late-binding VBA in Excel '97 with Netscape Messenger 4.73 as the default email client - yes it's a crappy setup, that's why I'm trying something neutral like CDO).

It seems that no matter how I set the "senduser" field I get this same error. I've tried setting a reasonable value for every other field and I still get the error.

Anyone have a clue about this?

Thanks,

James