Sending E-Mail

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

E-mail is one of the most important avenues of communication within large organizations, and for good reason. E-mail is not dependent on time or place; messages can be sent at any time of the day or night, and they can be accessed from practically anywhere. The fact that it might be after hours or that you do not know the physical location of the recipient is no deterrent to sending information via e-mail.

For that matter, the fact that no human being is present is also no deterrent to sending information via e-mail. You can include code that enables your scripts to send e-mail in response to a specified event. For example, a monitoring script can be coded so that it sends an e-mail message anytime disk space begins to run low on a server. An inventory script can retrieve information and then, instead of saving that information to a file, e-mail it to the appropriate administrator.

You can use the Collaboration Data Objects (CDO) technology to incorporate e-mail messaging within a script. CDO includes a COM component (Cdosys.dll) that can be used to send e-mail messages by using either the SMTP or the NNTP protocol. These messages can be sent even if the SMTP or NNTP service is not installed locally; you can use CDO to send messages as long as the SMTP or NNTP service is installed somewhere on your network.

The CDO automation library defines a number of objects, including the Message object, which represents a complete e-mail message. In turn, the Message object has a number of interfaces, including the IMessage interface. This interface is used to perform such tasks as addressing, adding content to, and sending a message.

Some of the key properties of the IMessage interface are shown in Table 17.9.

Table 17.9   IMessage Interface Properties

Property/MethodDescription
AddAttachmentEnables you to add an attached file to the message. As the AddAttachment parameter, specify the full path name of the file to be attached.
FromE-mail address of the primary author of the message. This property is optional; if left blank, the From property will be set to the value of the Sender property, assuming a value for this property has been configured. If neither the From property nor the Sender property is configured, the script will fail.
ReplyToE-mail address or addresses that replies should be sent to.
SenderE-mail address of the person who actually sent the message. This does not have to be the same address as the From property. If the From and Sender properties refer to the same person, you do not need to configure the Sender property.
SubjectSpecifies the subject line for the e-mail message.
TextBodyPlain-text representation of the actual e-mail message.
ToSpecifies recipients of the message.

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net