Windows Scripting
  Home arrow Windows Scripting arrow Sending Emails Using CDO in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Sending Emails Using CDO in WSH
By: Nilpo/Developer Shed Staff Writer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2007-04-03

    Table of Contents:
  • Sending Emails Using CDO in WSH
  • Preparing your message
  • Configuring the SMTP server
  • Sending HTML messages

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Sending Emails Using CDO in WSH


    (Page 1 of 4 )

    Whether you want start an in-house newsletter or you’d like email notification when machines log in and off of your network, there are plenty of reasons to incorporate emailing into your scripts.

    In order to add email functionality to WSH, we’re going to have to make use of the Cdosys.dll library.  CDOSYS is an implementation of Collaborative Data Objects (CDO), formerly Active Messaging, a Microsoft technology for adding messaging capabilities to applications.  CDOSYS is available in Microsoft Windows 2000 and newer.  Older systems will need to use CDONTS.  Here’s a brief roadmap.  Note that this is not totally inclusive.  More details information can be found in MSKB 171440.

    Name

    Version

    Library

    ProgID

    Release

    Active Messaging

    1.1

    OLEMSG32.DLL

    MAPI

    Exchange 5.0

    CDO 1.2.1

    1.2.1

    CDO.DLL

    MAPI

    Exchange 5.5, Outlook 98, Outlook 2000, Exchange 2000 Server

    CDO 1.2 for Windows NT Server

    1.2

    CDONTS.DLL

    CDONTS

    Exchange 5.5, Windows NT 4.0 SP1, IIS 4.0, MCIS, Windows 2000 Server

    CDO for Windows 2000

    6.0

    CDOSYS.DLL

    CDO

    Windows 2000 Server, Windows XP, Windows Server 2003

    I’m assuming that most of you reading this will be using Windows 2000 or newer so I won’t be covering the use CDONTS.  If you are trying to implement CDONTS you can ask me questions in the article blog.  Since it is legacy and has several limitations I didn’t feel it warranted much attention, however, the syntax is very similar.

    To begin, you’ll need to connect to the CDOSYS namespace by making a call to its ProgID.

    Set objMessage = CreateObject("CDO.Message")

    Next you’ll have to set your email fields, so let’s take a look at some syntax.  You should note that the CDO syntax is far beyond the scope of this article so I certainly won’t be covering the whole topic.  I’m only going to be covering the most common parts and the extras that I think would be most useful for the common reader.  You can find much more complete documentation on CDO 2.0 by visiting Microsoft’s MSDN site for CDO for Windows 2000.

    More Windows Scripting Articles
    More By Nilpo/Developer Shed Staff Writer


       · In this article I'm going to show you how to add email capabilities to your scripts...
       · This is very good, but the object name on page 3 should be objMessage not...
       · You are exactly right. Thanks for the correction.
     

    WINDOWS SCRIPTING ARTICLES

    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory
    - Moving and Renaming Computers with Active Di...
    - Working with System Processes in WSH





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway