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
Information
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
- Can Dell Truly Regain Its Top Spot - By: Carl Winston
Dell has been working hard to regain it top position in the global PC industry, deploying various strategies related to operations and production. But will it succeed? - Should You Use Cloud Computing - By: Carl Winston
Cloud computing has become rather well-know and can facilitate you or your business in a number of ways. - Renting a Storage Unit - By: Ellerbrock Catina
You may need a storage unit for a variety of reasons. You could be moving out, or renovating your home, or downsizing from a bigger home to a smaller one, or your possessions may simply have outgrown the space in your home. You can find an appropriate self storage facility either through the yellow pages or through an online search. You need to select a facility that is convenient, a facility that is somewhere in your neighbourhood. - US and Japan in the Tech Mix - By: Darwin Redshield
I'd like to take an opportunity to examine several recent examples of successful and unsuccessful cross-pollinations between the Japanese and American technology industries. - The Variety of Styles Available of a Laptop Desk or Laptop Table - By: MJ Marks
With the advent of the laptop computer comes the need to use them in comfort. Using a laptop on a chair or in bed often leads to neck and back strain, but by using a laptop table or laptop desk, much of this can be avoided. Take a look at the two basic designs available to find what would work best for you. - All Pro Solutions' Zeus Series - The Difference Between Synchronous and Asynchronous Modes - By: Christian Czentye
This article describes the main differences between synchronous and asynchronous modes of duplication with the Zeus series by All Pro Solutions. In synchronous duplication, Publisher uses all of the optical drives to burn the same disc image. In asynchronous duplication, Publisher uses each optical drive to burn independently, so each optical drive can be burning a different disc image. - Mapping Ancient Egyptian Sites with GPS and Imagery - By: Michiel Van Kets
C. Jason Smith is an associate professor at the City University of New York, LaGuardia and founder of the freelance writing collective Discipline & Publish. - Online Poker Rooms: The best places for minting money - By: Melville Jackson
he software is stable and responsive. Even with more than a thousand players using it simultaneously, the software has never crashed or slowed down till date. - Play Texas Hold 'em online: Get connected with your buddies - By: Melville Jackson
Texas Hold 'em poker (also called Texas Holdem or Texas Hold'em) is one of the most popular card games available today. - Data Centre Solutions: Outsource the IT Infrastructure for Business Success - By: Isla Campbell
When a company outgrows their existing IT infrastructure, what are the options available to them?
