Winbatch support for the Internet Mail Client Control Library
You can use the Internet Mail Client Control Library (CSMail) through the inbuilt COM/OLE support of the Winbatch programming langauge.
In most cases the standard release of CSMail will be all that you need. (You can download an evalution copy of the library here).
Restrictions in the Winbatch syntax and how to work around them
There are two restrictions in the Winbatch syntax which make coding with COM/OLE libraries a little more verbose than other automation enabled languages such as vbscript.
Winbatch Syntax Restriction 1 - Only single level of object model hierarchy is allowed in a single statement
This is nuisance when accessing hierarchical models; we might like to write:
But Winbatch requires that we break it down as follows:
Winbatch Syntax Restriction 2 - Parentheses are not allowed on the left side of an assignment statement
To assign a value to an item in an COM/OLE collection we might like to write:
Unfortunately Winbatch does not allow this syntax. Fortunately if the COM/OLE collection exposes standard automation collection methods we can work around this:
With a couple of exceptions (for which a patch is available see below) all the collection objects in CSMail support standard OLE collection operations and so can be used in WinBatch.
Using the CSMail objects in Winbatch
You can create an instance of any of the CSMail objects with the Winbatch
After creating an object you can access the properties and methods documented in the manual. (The manual is also included in the standard installation).
So, for example, to set the subject of the message we created above:
Then we can set the recipient and originator of the email:
To complete the message we need to add a message body:
Finally we can create an SMTPClient object and send the message we just created:
There are a couple of collection properties in the CSMail object model which do not expose the full set of standard automation collection methods. Specifically these are the Option property of the Settings object and the Item property of the Header object.
While these collections are not always required in normal usage of the CSMail library we have created a patched version of the library with Winbatch-friendly alternatives. You can download the patched library below.
After downloading the patch you should replace the copy of csmail.dll created by the standard installation with the patched version. (The standard installation usually creates csmail.dll in
The patched library adds the following two methods to the library:
|Copyright © 1996-2004 Codestone Ltd.|