31 August 2006

Sending mail through vbscript natively

For those who want to send mail direclty from a vbscript, but without any third damn thing, here is a great function:


Sub SendMail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = me@me.com
objEmail.To = "you@you.com"
objEmail.Subject = "this is my subject"
objEmail.Textbody = "this is my body"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
Set objEmail = Nothing
End Sub

tested on XP, 2000, 2003, without Outlook installed, and without any  access to internet

No comments: