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.
Next: Preparing your message >>
More Windows Scripting Articles
More By Nilpo/Developer Shed Staff Writer