24602

How can I send an e-mail from a vbs script

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 = "me@example.com" objEmail.To = "me@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)

Answer1:

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?

Answer2:

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

Answer3:

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..

Recommend

  • Beaglebone Black Persistent Internet Over USB - Debian Image 2016-05.13 am335x_evm.sh
  • Email a text file's content in html format
  • Getting “system.net.sockets.socketexception no such host is known” in Unity WebGL build
  • Sending e-mail without refresh the page
  • Sending email using Batch file
  • Running a script in FreeBSD after boot/reboot
  • How to remove index.php from codeigniter on Bitnami MAMP stack
  • Office 365 and Classic ASP vs. VB.net SMTP Settings
  • Java Mail: Getting Bounced Messages To Go To An Address Different From The Sender
  • How to use the resource module to measure the running time of a function?
  • How can i dump blob fields from mysql tables
  • How to assert that an input element is empty in Ruby on Rails tests
  • Returning the auto incrementing value after an insert using slick
  • Magento get URL before current
  • Why must we declare a variable name when adding a method to a struct in Golang?
  • Inline R code in YAML for rmarkdown doesn't run
  • Install PHP intl extension on MacOS
  • Django simple Captcha “No module named fields” error
  • Retrieve list of sent friend requests from friend_request FQL table
  • Rails Find when some params will be blank
  • NHibernate Validation Localization with S#arp Architecture
  • How can I send an e-mail from a vbs script
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Accessing IRQ description array within a module and displaying action names
  • Can Jackson SerializationFeature be overridden per field or class?
  • Adding custom controls to a full screen movie
  • Invalid access key error using credentials redeemed from an amazon open id token
  • retrieve vertices with no linked edge in arangodb
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How to set the response of a form post action to a iframe source?
  • Understanding cpu registers
  • how does django model after text[] in postgresql [duplicate]
  • Getting Messege Twice Using IMvxMessenger
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • Add sale price programmatically to product variations
  • reshape alternating columns in less time and using less memory
  • How to push additional view controllers onto NavigationController but keep the TabBar?