Sendmail via VBscript

This is a fun one, you can find numerous examples of this script all over the internet. Figured I’d share…


Set objEmail = CreateObject("CDO.Message")
objEmail.From = "from@domain.com"
objEmail.To = "to@domain.com"
objEmail.Subject = "My Subject"
objEmail.Textbody = "Only use if you want to send a text email and not an HTML email"
objEmail.HTMLBody = "" &_
"
" &_ "HTMLPretty Font lalallala " &_ "
AIS-IUS" &_ "More pretty font HTML woot
" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _ "{your mail server}" objEmail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = {mail server port} objEmail.Configuration.Fields.Update objEmail.Send

This sends a pretty simple text email. If you want to send an HTML email simple craft your HTML in your favorite text editor and copy and past it to the line:



objEmail.HTMLBody = "HTMLCODE" 

Use &_ to append to the next line.

Leave a Reply

↓