Vbscript send mail

A classic!

Here's a simple example of how to send an email using VBScript:

' Set the email server and port
Dim objMail
Set objMail = CreateObject("CDO.Message")

objMail.From = "[email protected]"
objMail.To = "[email protected]"
objMail.Subject = "Test Email"
objMail.TextBody = "This is a test email sent using VBScript"

' Set the email server and port
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your_email_server"
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

' Save and send the email
objMail.Configuration.Fields.Update
objMail.Send

' Clean up
Set objMail = Nothing

Make sure to replace the placeholders with your actual email server, port, and email addresses.

Here's a breakdown of the code:

  1. We create a CDO.Message object, which is a COM object that allows us to send emails.
  2. We set the From, To, Subject, and TextBody properties of the email.
  3. We set the email server and port using the Configuration object. In this example, we're using a simple SMTP server on port 25.
  4. We update the configuration and send the email using the Send method.
  5. Finally, we clean up by setting the objMail object to Nothing.

Note that this code assumes you have the CDO (Collaboration Data Objects) component installed on your system. If you don't have it installed, you can download it from the Microsoft website.

Also, keep in mind that this is a basic example, and you may want to add more features to your email script, such as attachments, HTML formatting, or error handling.