Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
Sending E-mail from a Command Prompt Using the IIS SMTP Service
Article ID: 193685 - View products that this article applies to.
This article was previously published under Q193685
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
The Windows NT Option Pack (NTOP) includes a Simple Mail Transfer Protocol (SMTP) service for Internet Information Server (IIS). Also included in the Option Pack is the Windows Script Host (WSH), which is a powerful batch processing language interpreter, allowing administrators to write scripts in Visual Basic Script (VBS) or JScript (JS). Together the SMTP service and WSH can be used to send e-mail from a command line.
With the SMTP service installed, a new system object named "CDONTS.NewMail" can be used to send mail with a few lines of code.
The following example using VBS and WSH demonstrates how to send -email from a command prompt. Save the code shown below as SENDMAIL.VBS, open a command prompt session. and call the code using the following syntax:
CSCRIPT.EXE SENDMAIL.VBS -?
This will return the Help screen that shows the syntax for using the script. This script can be used inside batch files, or for other purposes such as sending alerts from Performance Monitor.
Save the following VBS code as SENDMAIL.VBS: