Windows 2000 and Windows XP use CDO messaging as a replacement for CDONTS. Sending email with CDO is a simple task.
First we create a reference to the CDO component
Set objMessage = CreateObject("CDO.Message")
then fill-in Sender, Subject and Recipient (To) fields of the headers and the body text which can be either plain text or HTML. You can also add a file attachment. You then use the Send method to send the email.
Set oMessage = CreateObject("CDO.Message")
oMessage.Subject = "Example CDO Message"
oMessage.Sender = "me@my.com"
oMessage.To = "test@test.com"
oMessage.TextBody = "This is some sample message text."
oMessage.AddAttachment "c:\temp\readme.txt"
oMessage.Send
Posted in CDO Component


daniva




April 17th, 2008 at 3:10 am
I wonder how the message is sent. There is no reference to the smtp server or exchange server. I get the following error : “The “SendUsing” configuration value is invalid”. Any Idea ?
April 17th, 2008 at 3:32 am
Nevermind. I figured it out. You may have to add this also before the line oMessage.Subject…. Thanks for this article daniva. :)
‘==This section provides the configuration information for the remote SMTP server.
‘==Normally you will only change the server name or IP.
oMessage.Configuration.Fields.Item _
(”http://schemas.microsoft.com/cdo/configuration/sendusing”) = 2
‘Name or IP of Remote SMTP Server
oMessage.Configuration.Fields.Item _
(”http://schemas.microsoft.com/cdo/configuration/smtpserver”) = “yoursmtpserver.com”
‘Server port (typically 25)
oMessage.Configuration.Fields.Item _
(”http://schemas.microsoft.com/cdo/configuration/smtpserverport”) = 25
oMessage.Configuration.Fields.Update
June 18th, 2008 at 12:01 pm
Can any one help in getting the Emails if any problem in script/error while running in script automaticallly to the recipients added in the above function given for CDO based Emails.
June 18th, 2008 at 12:05 pm
please advise me to have a database based framework rather getting data from XL.Currently I am using XL based framework and i faced many problems so I am in idea of getting datas from database tables.Please if any body knows the concept of getting from database.One kind info I know how to connect with the database and running the query from there.But I want some sample script for executing it.
July 6th, 2008 at 6:37 am
Is there any pre-condition for setting Report Server to be used for the Email. I am not able to send the emails. It says ” The transport failed to connect to the Server”.
September 16th, 2008 at 8:30 am
Outlook express should be installed in your server or m/c. Then
Set objMessage = CreateObject(”CDO.Message”)
objMessage.Subject = “Hello”
objMessage.From = “xx@xx.com”
objMessage.To = “xx@xx.com”
objMessage.Send
The above code is enough to send the mail