Thursday, January 15, 2009

Simple VB Script to Email File

Creating an email and sending it with an attachment via VB is pretty simple. You can just adjust the following and use however you wish.

set objEmail = CreateObject("CDO.Message")
objEmail.From = ""
objEmail.To = ""
objEmail.Subject = "Subject Here"
objEmail.TextBody = "Message Here"
objEmail.AddAttachment "C:\"
objEmail.Configuration.Fields(" configuration/sendusing") = 2
objEmail.Configuration.Fields(" configuration/smtpserver") = "server" objEmail.Configuration.Fields.Update objEmail.Send

No comments: