How can I send an e-mail from a vbs script - on a machine that cannot connect to the internet (it's in my non-internet zone).
I've hacked the following together from my googling, but is seems to require a call to Microsoft's server. What about the situation where I'm not able to reach microsoft.com?
sch = "http://schemas.microsoft.com/cdo/configuration/" Set cdoConfig = CreateObject("CDO.Configuration") With cdoConfig.Fields .Item(sch & "sendusing") = 2 ''cdoSendUsingPort .Item(sch & "smtpserver") = "my_internal_mail_server" .update End With Set objEmail = CreateObject("CDO.Message") set objEmail.configuration = cdoConfig objEmail.From = "firstname.lastname@example.org" objEmail.To = "email@example.com" objEmail.Subject = "Server is down!" objEmail.Textbody = "Run out the guns!!!" objEmail.Send MsgBox "Script Complete"
(I have an internal SMTP server... the problem is having to poll the MS server)
You need a SMTP server that is accessible from where your script will run that knows how to send the email to where it needs to go. You can configure IIS or Exchange to do SMTP (or any number of open source projects), but it needs to be configured so it can relay the email to where it needs to go.
EDIT: I was under the impression that the schema was just a namespace for the configuration fields, not something that it actually tried to load from a microsoft server. When you run it, giving it your internal smtp server name, what happens? Do you get an error?
An alternative if you want quick and dirty is blat which is a command line utility for sending mail via SMTP. http://www.blat.net
I'm in such a situation at work, we have only one SMTP server that can do mailing but have scripts all over the place who need to do mailing too. So i append the mail as a one line text string to a file on the SMTP server where a VBS script is scheduled that reads this file ands sends out the mails. If you're interested i publish it here tomorrow. Hope it helps..