Tuesday, September 26, 2006
Send E-mail Using Visual Basic Script (VBS)
I've created the following template for the company I work for to send out reminder e-mails that we schedule. You can run this on a Windows 2000 Server, Windows XP Pro or Windows Server 2003 system that has the SMTP service installed on it.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Script Objective: To send out an e-mail reminder to a user or group of users
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' To use this file modify the lines below with the e-mail address(es) to send
' the e-mail to, the subject line and the text body. You can also include
' file(s) with the message if desired.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This creates the message object, do not change!
Set m = CreateObject("CDO.Message")
' This line adds the text for the e-mail subject line
' Sample: m.Subject = "Reminder: Please remember to do this!"
m.Subject = ""
' This line adds the text for the e-mail FROM address. This needs to be
' included otherwise the message will be rejected
' Sample: m.From = "user@host.com"
m.From = ""
' This is the address to send the message to. You can include multiple
' e-mail addresses by seperating them with a comma
' Sample: m.To = "user@host.com,user@host.com"
m.To = "alerts@office.local,troy.murray@gmail.com"
' This is the carbon copy address to send the message to. You can include
' multiple e-mail addresses by seperating them with a comma
' Sample: m.CC = "user@host.com,user@host.com"
m.CC = ""
' This is the blind carbon copy address to send the message to. You can
' include multiple e-mail addresses by seperating them with a comma
' Sample: m.BCC = "user@host.com,user@host.com"
m.BCC = ""
' This is the text of the message body. You can create a new paragraph by
' using the return character (vbCrLf) and you can append text to the previous
' line to shorten each section of text you might have.
' Sample: m.TextBody = "First line of text!"
' Sample: m.TextBody = m.TextBody & vbCrLf & "Second line of text!"
m.TextBody = ""
' Use this line to send an attachment with the message, add as many attachments
' as you wish using a new line for each new one
' Example: m.AddAttachment "c:\temp\readme.txt"
' This sends the message on it's merry way
m.Send
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment