views:

60

answers:

2

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 = "[email protected]"
objEmail.To = "[email protected]"
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)

+2  A: 

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?

ongle
Yup... already have one on the same network. How do I tell it to go there? Without having to poll http://schemas.microsoft.com
CodeSlave
Does it actually poll for the schema?
ongle
No, those are just "strong names" akin to using a GUID as a collection key. They are not real URIs and there is no attemmpt made to contact the server. Even if you enter one in a browser you'll get no response.
Bob Riemersma
A: 

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

Michael Baker