Small VB Script to send email with attachment

Open notepad and save the file as .VBS

const cdoBasic=1
schema = “http://schemas.microsoft.com/cdo/configuration/
Set objEmail = CreateObject(“CDO.Message”)
With objEmail
.From = “email@company.com
.To = “email@company.com
.Subject = “Events for ” & date
.Textbody = “logs ” & Chr(10) & “email”
.AddAttachment “c:\Event.txt”
with .Configuration.Fields
.Item (schema & “sendusing”) = 2
.Item (schema & “smtpserver”) = “mail.company.com”
.Item (schema & “smtpserverport”) = 25
.Item (schema & “smtpauthenticate”) = cdoBasic
.Item (schema & “sendusername”) = “email@company.com
.Item (schema & “smtpaccountname”) = “email@company.com
.Item (schema & “sendpassword”) = “SomePassword”
End With
.Configuration.Fields.Update
.Send
End With

This entry was posted in Scripts. Bookmark the permalink.

Leave a Reply