Home > Enterprise Desktop Tips > > VBScript does mail
Enterprise Desktop Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 


VBScript does mail


Patrick Sklodowski, Contributor
01.31.2005
Rating: -4.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Please let us know how useful you find this tip by rating it below!


Use this sub to send e-mail messages from your script. This script works on Windows 2000, and may work on NT 4.0 if the correct CDO library is installed.

This sub requires the SMTPserver, From address, Recipient address, Subject, and Message be passed as arguments.

A couple of general comments:

' Begin example
SMTPServer = "smtphost.domain.com"
Recipient = "you@yours.com"
From = "me@mine.com"
Subject = "Test email"
Message = "This is a two line test message" & vbcrlf & "Did you get it?"

' To add an attachment update the full path and uncomment the line
' There is one line below that must also be uncommented


'attachment = "c: \ test.txt"

' Call Sub and pass required data
GenericSendmail SMTPserver, From, Recipient, Subject, Message

' Begin Sub
' ------------------------------------------------------------------
' Generic function to send mail using a remote
' SMTP ser


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Windows legacy operating system management
Windows 2000 batch file command reference
Using CMD.exe and Command.com
Microsoft's Allchin to retire in 2006
Freeware tool purges empty directories
Transplant user profile folders during upgrades
Use 'Clonepr' to move users between AD forests
Establishing a TCP/IP connection between a Win2k app and a mainframe app
Change a local admin password with Local Security Utility.exe
Windows Server 2003 management tools: Remote Desktop for Administration
Boost performance: change Group Policy refresh interval

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Error messages for Windows 2000  (SearchEnterpriseDesktop.com)
IO.SYS  (SearchEnterpriseDesktop.com)
MS-DOS  (SearchEnterpriseDesktop.com)
W2K  (SearchEnterpriseDesktop.com)
Windows 2000  (SearchEnterpriseDesktop.com)
Windows 98  (SearchEnterpriseDesktop.com)
Windows XP  (SearchEnterpriseDesktop.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


ver. Pass SMTPserver, From address,
' Recipient address, Subject, and Message as arguments
' ------------------------------------------------------------------
Sub GenericSendmail (SMTPserver, From, Recipient, Subject, Message)

set msg = WScript.CreateObject("CDO.Message")
msg.From = From
msg.To = Recipient
msg.Subject = Subject
msg.TextBody = Message

' To add an attachment uncomment this line
'msg.AddAttachment attachment

msg.Configuration.Fields ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
msg.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

msg.Configuration.Fields.Update

msg.Send

End Sub


Patrick Sklodowski is a Microsoft Certified Systems Engineer with over eight years of industry experience. His specialties include Windows NT/2000, Active directory, SMS, Exchange and scripting. He is currently working as a Senior Engineer with a global provider of engineering solutions and specialized staffing.

Rate this Tip
To rate tips, you must be a member of SearchEnterpriseDesktop.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Enterprise Desktop Security - Virus Protection, Malware Protection, Intrusion Detection
HomeTopicsITKnowledge ExchangeTipsMultimediaWhite PapersBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2008 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts