Vbs send email

A classic!

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

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

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

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

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

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.

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.