Categories
- Arts & Entertainment
- Business
- Communications
- Computers
- Culture & Society
- Disease & Illness
- Fashion
- Finance
- Food & Beverage
- Health & Fitness
- Hobbies
- Home & Family
- Home Based Business
- Internet Business
- Legal
- Pets & Animals
- Politics
- Product Reviews
- Recreation & Sports
- Reference & Education
- Religion
- Self Improvement
- Shopping
- Travel & Leisure
- Vehicles
- Writing & Speaking
VBScript - Send E-Mail with CDO.Message
Submitted: 2007-01-17 16:02:35
Print this article | Tell a friend | For publisher |
Some my feel that apart from it being a nifty trick, there isn’t any real practical use for sending E-Mail from a script but lets imagine the following scenario:
You have a business critical server called "ImpServ01" that must be available at all costs. The following script can be setup to run every five minutes to check the availability of the server and email you if the server becomes unavailable. This example uses a SMTP server called "SMTP.YourDomain.com" and sends mail from "ImpServ01@YourDomain.com" to "Admin@YourDomain.com".
Option Explicit
Dim strComputer Dim colPingStatus Dim objPingStatus Dim objMessage
strComputer = "ImpSrv01"
Set colPingStatus = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("SELECT * FROM Win32_PingStatus WHERE address = '" & strComputer & "'")
For Each objPingStatus In colPingStatus
If IsNull(objPingStatus.StatusCode) or objPingStatus.StatusCode <> 0 Then
Set objMessage = CreateObject("CDO.Message")
objMessage.From = strComputer & "@YourDomain.com"
objMessage.To = "Admin@YourDomain.com"
objMessage.Subject = strComputer & " is unavailable"
objMessage.Textbody = strComputer & " is no longer accessible over the network."
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP.YourDomain.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
End If Next
Set colPingStatus = Nothing Set objMessage = Nothing
To attach a file to the E-Mail add the following line:
objMessage.AddAttachment "SomeDocument.doc"
Shaun Vermaak - www.ITtelligence.co.za |
Article source: Expert Articles
Most Recent Articles in Computers category
- Get Quality Sound From Your Computer - By: Kamal Ashwani
The computer has become one of the most commonly used electronic devices, and is regarded as an important means of gaining information and knowledge. With the rolling time span the computer has played a major role in the field of business, education sector. Gradually it has also transformed itself into an entertainment device - Your Way To Success - By: Surjeet Kumar
Did you know, self-publishing is one of the easiest ways to make money on the web. Of course, it requires talent, but it's easier to learn than you might think. Getting Started: - Remove The Pesky Spyware with Spyware Cleaner - By: Surjeet Kumar
Experiencing PC problems? You might be a victim of spyware. Of the numerous PC problems today, this is one of the most common dilemmas experienced by users. Thankfully, there's a way on how this can be solved: by getting a spyware cleaner! Anti-spyware or spyware cleaners are programs specially designed to take out spyware from infected PCs. - When Buying A New Computer Save Money - By: Manojj Kumarr
For most people, buying a new computer does not have to be as stressful as buying a new car. Nor does it have to be as expensive. If you're like most people, and you have a limited budget for buying a computer, then you need to try to get as much computer for your money as possible. - Secure Digital Card Digital Card - By: Dharmender Kumar
Secure Digital Cards (or SD cards) are flash memory cards format developed for use in portable devices like Digital Cameras, Handheld computers, PDAs, Mobile Phones, GPS receivers and video game consoles too. - When Buying a Toner Don't Break the Bank - By: Manojj Kumarr
There's a conspiracy afloat. You go to your local office supply store or membership warehouse, and find the deal of the century on a laser printer, photo printer, or inkjet printer. You take it home and are delighted by the quality of the prints, the speed of the printer, and most of all, that your new printer was incredibly inexpensive. - Information About Cisco CBAC - By: Ravii Kumarr
The Cisco IOS Firewall Feature Set is a module that can be added to the existing IOS to provide firewall functionality without the need for hardware upgrades. - Twenty Five Things Mapping Software Can Do For You - By: Ankur Bhardwaj
There are a number of things that we can do with our mapping software. It would be better said that the mapping software can actually map our entire lives onto our system. These include making the world within our reach just by the click of a button. There are so many things that can be done with the help of this mapping. You can plan just about everything in your life with the help of this software. - A new version English German dictionary Translate It for Windows - By: Ajaay Kumar
See The Meaning Of Words By Simply Moving Your Mouse. No Clicks Required! Do you frequently browse Web pages in foreign languages? Do you often work with documents written by your German Russian counterparts? - Both sides of the Coin called Google Ad words - By: Manishh Kumarr
By now most of you realize that Google can give our websites the ability to appear within their results pages using a Pay Per Click model (PPC).
