Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to test CDO email using VB Script.

Total Hit ( 3462)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Sometimes we need to check CDO on the server with minimum amount of time.

Following script will send an email using CDO object library. If you dont have CDO then it will throw an error.

- Create an empty file in notepad.
- Copy/Paste the following script
- Save file as CDOMailTest.vbs
- Double click the file to test CDO

CDOMailTest.vbs

Click here to copy the following block
Dim objMessage ,strTo,strSmtp

strTo=InputBox("Enter [To] email address",,"someone@hotmail.com")

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "someone@binaryworld.net"
objMessage.To = strTo

'objMessage.Cc = strTo
'objMessage.Bcc = strTo

objMessage.TextBody = "This is some sample message text."

strSmtp=InputBox("Enter SMTP server name or IP (i.e. mail.bellsouth.com)",,"localhost")

if strSmtp<>"localhost" then
   '==This section provides the configuration information for the remote SMTP server.
   '==Normally you will only change the server name or IP.
   objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

   'Name or IP of Remote SMTP Server
   objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSmtp

   'Server port (typically 25)
   objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

   ''//If SMTP requires authentication then use below lines
    'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
    'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =  "username@abc.com"
    'objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =  "mypassword"

   objMessage.Configuration.Fields.Update
   '==End remote SMTP server configuration section==
end if

'//Uncommnet the following lines to test email with attachments
'//objMessage.AddAttachment "c:\test1.txt"
'//objMessage.AddAttachment "c:\test2.txt"

objMessage.Send

Msgbox "Message sent to " & strTo



Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.