WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder



Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : The purpose of this article is to describe the process in creating scheduled mail-outs using Windows Scripting Host (WSH) and the email features of the SMTP service's CDONTS.NewMail object.
Categories : WinNT, IIS, Email, Web Servers
Boaz Yahav
Date : Apr 25th 1999
Grade : 5 of 5 (graded 1 times)
Viewed : 15187
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

The information in this article applies to:

- Microsoft Internet Information Server versions 4.0, 5.0
-------------------------------------------------------------------------------

SUMMARY
=======

Windows NT Option Pack (NTOP) and Windows 2000 install by default a Simple Mail
Transfer Protocol (SMTP) service that can be used for a variety of purposes,
usually using Active Server Pages (ASP) for email-based HTML form handling.

The purpose of this article is to describe the process in creating scheduled
mail-outs using Windows Scripting Host (WSH) and the email features of the SMTP
service's CDONTS.NewMail object.

MORE INFORMATION
================

The following example will step you through creating a WSH script to send mail,
as well as a text file that you can update for the mail contents, and a
scheduled task to send the mail.

1. The first step in setting up any scheduled activity is to ensure that the
scheduler service is running"
a. Click "Start" on the task bar, then click "Settings" and "Control Panel"

b. Double-click the "Services" applet in "Control Panel"

c. Scroll down to the "Task Scheduler" service

d. Ensure that "Status" states "Running"

e. Ensure that "Startup" states "Automatic"

f. Click "Close" to exit the services applet and close "Control Panel"

2. Next, create a text file with the following contents and save it as
"C:\MAILOUT.TXT" on your computer.
<p>This is line 1.</p>
<p>This is line 2.</p>

3. The next step is to create the WSH script to read the text file we just
created. Copy the following code and save it as "C:\MAILOUT.VBS" on your
computer. To customize the sender/receiver, change the value of the "strFrom"
and "strTo" variables.
'--------------------------------------------------------------------
'
' Mailout using CDONTS.NewMail
'
'--------------------------------------------------------------------

' declare all variables
Option Explicit
Dim objSendMail
Dim strTo, strFrom
Dim strSubject, strBody

' mail constants (some are for reference)
Const CdoBodyFormatHTML = 0 ' Body property is HTML
Const CdoBodyFormatText = 1 ' Body property is plain text (default)
Const CdoMailFormatMime = 0 ' NewMail object is in MIME format
Const CdoMailFormatText = 1 ' NewMail object is plain text (default)
Const CdoLow = 0 ' Low importance
Const CdoNormal = 1 ' Normal importance (default)
Const CdoHigh = 2 ' High importance

strFrom = "[email protected]" ' change to your email address
strTo = "[email protected]" ' change to the recipient's address
strSubject = "Test Message" ' change to your subject

' this line calls the ReadFile() function to read the page contents
strBody = ReadFile("C:\MAILOUT.TXT")

' this line calls the MakePage() function to format the page as HTML
strBody = MakePage(strSubject,strBody)

' the following section creates the mail object and sends the mail
Set objSendMail = CreateObject("CDONTS.NewMail")
objSendMail.From = strFrom
objSendMail.To = strTo
objSendMail.Subject = strSubject & " (" & Date() & ")"
objSendMail.Body = strBody

objSendMail.BodyFormat = CdoBodyFormatHTML
objSendMail.MailFormat = CdoMailFormatMime
objSendMail.Importance = CdoNormal

objSendMail.Send
Set objSendMail = Nothing

' this function returns a properly formatted HTML page
Function MakePage(txtSubject, txtBody)
Dim txtTemp
txtTemp = "<HTML>" & vbCrLf
txtTemp = txtTemp & "<HEAD><TITLE>"
txtTemp = txtTemp & txtSubject
txtTemp = txtTemp & "</TITLE></HEAD>" & vbCrLf
txtTemp = txtTemp & "<BODY>" & vbCrLf
txtTemp = txtTemp & "<H2>" & txtSubject & "</H2>" & vbCrLf
txtTemp = txtTemp & txtBody & vbCrLf
txtTemp = txtTemp & "</BODY>" & vbCrLf
txtTemp = txtTemp & "</HTML>"
MakePage = txtTemp
End Function

' this function opens a file and returns the file's contents
Function ReadFile(txtFile)
Dim txtTemp, objFS, objFL
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFL = objFS.OpenTextFile(txtFile)
Do While Not objFL.AtEndOfStream
txtTemp = txtTemp & objFL.ReadLine
txtTemp = txtTemp & vbCrLf
Loop
objFL.Close
Set objFS = Nothing
ReadFile = txtTemp
End Function

4. Next you will need to create a task to schedule the mail-out to be sent. Open
a command session and enter something like the following examples:
a. The following task will run once at 9:00pm
AT 9:00pm CSCRIPT.EXE C:\MAILOUT.VBS

b. This task will run every Monday at 6:00am
AT 6:00am /every:M CSCRIPT.EXE C:\MAILOUT.VBS

c. This task will run on the first of every month at 1:00am
AT 1:00am /every:1 CSCRIPT.EXE C:\MAILOUT.VBS

5. Depending on the scheduled time that you chose for the task above, your email
will be sent when the time occurs.

For more information on Microsoft's scripting technologies, please see the
following web site:

http://msdn.microsoft.com/scripting/



windows nt php/3 file upload script
Categories : Filesystem, PHP, IIS, WinNT, Web Servers
This Knowledge Base article will briefly describe the steps involved to set up remote debugging for use with Visual InterDev Version 6.0
Categories : WinNT, Debugging, IIS, Web Servers
How to use the IIS Exception Monitor
Categories : IIS, Debugging, WinNT, Web Servers
Index Server FAQ
Categories : MS Index Server, WinNT, IIS, Web Servers
Setup IIS using only 1 ip address and 1 ssl key but have multiple websites
Categories : WinNT, IIS, Web Servers
How can i add mime types to IIS 3.0 and IIS 4.0?
Categories : IIS, WinNT, Web Servers
enable/disable the cookies system-globaly
Categories : IIS, Cookies, WinNT, Web Servers
how to activate connection pooling in IIS 3 and IIS 4, for access via ODBC to SQL Server 6.5
Categories : IIS, ODBC, MS SQL Server, Web Servers, Databases
making links from text
Categories : PHP, Regexps, Email
Protect your mailto: email addresses from bots
Categories : PHP, Email, Java Script
Class that allows the PHP developer to establish connections with a POP3 mail server amd be able to list, retrieve and delete mail messages from a given mail box.
Categories : Network, Email, PHP, PHP Classes
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
imap_subscribe -- Subscribe to a mailbox
Categories : PHP, PHP Functions, IMAP, Email
phpCMS a content-management-system written in php.
Categories : Content Management, Apache, Complete Programs, Web Servers, PHP