Sending e-mail - Ron deBruin

S

Steph

Hello everyone. I stole the following piece of code from Ron deBruin's web
site. I am trying to automatically send an e-mail without all the new
Outlook security prompts. The code I grabbed is below. But when I run, I
get a "The SendUsing Configuration value is invalid". Any idea how to fix?

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") = "Fill
in your SMTP server here"
'
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
' .Update
' End With

For Each cell In
Sheets("Sheet1").Columns("B").Cells.SpecialCells(xlCellTypeConstants)
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"" <[email protected]>"
.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
 
R

Ron de Bruin

Hi Steph

Have you read this text on my webpage
http://www.rondebruin.nl/cdo.htm
************************************

This code will not work in Win 98 and ME.
You must be connected to the internet when you run a example.

It is possible that you get a Send error when you use one of the examples.
AFAIK : This will happen if you haven't setup an account in Outlook Express.
In that case the system doesn't know the name of your SMTP server.
If this happens you can use the commented blue lines in each example.
Don't forget to fill in the SMTP server name in each code sample where
it says "Fill in your SMTP server here"
 
S

Steph

Hi Ron. I talked to my IT guy at work, and he told me our SMTP server was
mail.tp.com. I added that to the appropriate line of your code. But when I
ran it, got an "object required" error. Does mail.tp.com sound like an SMTP
server? Am I doing something else wrong? Thanks!
 
S

Steph

Never mind Ron. I didn't have the SMTP server name in quotes. Now it works
PERFECTLY!!! Thank you so much!!

-Steph
 

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