Telephone: (480) 722-1227 Toll Free: (888) 722-1227
  Email - Contact
  Register Login   |   Knowledge Base  >  Knowledge Base Systems  >  Windows  >  vbs script to send out email   |   Saturday, July 31, 2010 search:    
vbs script to send out email
Last Post 11 Dec 2007 09:29 AM by Chris Muench. 0 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Chris MuenchUser is Offline
New Member
New Member
Posts:57

--
11 Dec 2007 09:29 AM  

Call the script like this

wscript script_name.vbs

[vbs]

' Define who the email is sent from, must be in valid format (can be bogus address)
emailFrom = "from@example.com"
' Define who the email is sent To
email_arr = array("to@example.com","to2@example.com")
' Define the SMTP server to handle the email
SMTPserver = "smtp.example.com"
' Define the SMTP server port to used
'*** Line 40
SMTPport = "27"
'Define the SMTP username to send
SMTPuser = "smtp_username"
'Define the SMTP password for the above user
SMTPpasswd = "smtp_password"
' Send the email out
' split string into array
' loop through array and call SendEmail sub
for Each email in email_arr
  SendEmail(email)
next
sub SendEmail(emailTo)
' Define the action
Set objEmail = CreateObject("CDO.Message")
' Who, What, Where, When, Why, How
objEmail.From = emailFrom
objEmail.To = emailTo
' Edit the subject and body as required...
objEmail.Subject = "This is the Subject of the Email"
objEmail.Textbody = "This is your message body.  I usually include the timestamp inside " & Now()
' Define email server settings
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ver") = SMTPserver
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ate") = 1
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ame") = SMTPuser
'Your password on the SMTP server
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ord") = SMTPpasswd
'Server port (typically 25)
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ort") = SMTPport
'Use SSL for the connection (False or True)
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...ssl") = False
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/co...out") = 60
objEmail.Configuration.Fields.Update
' Send the EMAIL
objEmail.Send
End Sub
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

' Stop the script in case it doesn't automatically
WScript.Quit

[/vbs]

You are not authorized to post a reply.

Active Forums 4.2
Copyright 2006 - 2010 Vigilant Support   |  Privacy Statement  |  Terms Of Use