Saturday, August 25, 2007

VB Script to send email

VB Script to send email
==================

'this is self explainatory
strFrom = "from@domain.com"
strTo = "to@domain.com"
strSub = "Your subject"
strBody = "Your body"
strSMTP = "smtp.domain.com"

set objEmail = CreateObject("CDO.Message")
objEmail.From = strFrom
objEmail.To = strTo
objEmail.Subject = strSub
objEmail.Textbody = strBody
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
objEmail.Configuration.Fields.Update
objEmail.Send
WScript.Echo "Email sent successfully"


'obviously to run the above u need to configure the ports and configure smtp!!...otherwise above won't run.

No comments: