How to Create an Email in a VBScript

Visual Basic Scripting (VB Scripts) is a type of Visual Basic programming that is used in text files. The Windows operating system recognizes the scripts as executables and runs the lines of code on the local computer. These scripts are used in networks and added to machines to automate login procedures. VB Scripts can also send emails. The scripts use an email component called CDO. Using CDO, you can send an email from a VB Script file.

Instructions

    • 1

      Open Notepad or an existing VB Script file to add the email commands to the code. If this is a new file, save the new file to a location on the hard drive. Ensure you save the extension for the file as vbs, which triggers Windows to run the code instead of treating it like a normal text file.

    • 2

      Create the main mail CDO object variable. This instantiates the object, which means you load it into memory and the coder is able to call all the properties and methods associated with the object. Below is the code to instantiate the CDO object:
      Set cdoMail = CreateObject("CDO.Message")

    • 3

      Set the "To" and "From" properties for the CDO object. The "To" and "From" properties set the recipient and sender values. This is the code to set these values:
      cdoMail.From = "your_name@your_domain.com"
      cdoMail.To = "test@your_recipient.com"

    • 4

      Set the subject for the email. This is the same as entering a subject for an email in a regular client. The code to set the email subject is:
      cdoMail.Subject = "My Email Subject"

    • 5

      Send the message. Once the email is set up, you still need to call the "Send" function. The send function packages the email and sends it to the recipient. The code is:
      cdoMail.Send

    • 6

      Save the file to a location on your hard drive. To test the code, double-click the file on your hard drive and an email is sent to the recipient listed in the code.

Tips & Warnings

  • The CDO object uses the default outgoing and incoming server settings on the local machine. If the computer is not connected to the Internet, the process will fail.

Related Searches:

References

Comments

You May Also Like

  • How to Write VBScript

    VBScript lets you engage in active scripting from the browser side, much like you would with JavaScript. Visual Basic users may find...

  • How to Create a Mailbox in VBScript

    Network administrators who manage several computers can benefit from writing a Visual Basic script (VBScript) that automates the creation of a mailbox....

  • How to Check If a File Exists Using VBScript

    At times, when programming with VBScript, a programmer will want to know if a file exists prior to performing another function. This...

  • How to Create Word Documents With VBScript

    Visual Basic Scripting (VBScript) is a lightweight programming language that provides network administrators with the ability to automate user processes. The ...

  • How to Zip Files Using VBScript

    VBScripts allow Microsoft users to create basic programs with local Microsoft data and objects. ZIP files are actually folders that have been...

  • How to Send HTML Email With CDO

    CDO provides Visual Basic (VB) coders with the ability to send email from their website. CDO is an email object in VB,...

  • How to Learn VB Script Online

    VBScript, or Visual Basic Script, is a type of scripting language developed by Microsoft in 1996. A scripting language is a specific...

  • How to Create a VBS Email

    One part of automation for websites and desktop applications is sending email to customers. You can automate the procedure using Visual Basic...

  • How to Copy and Paste Email Into Excel With VBS

    Microsoft Excel is the spreadsheet program included in the Microsoft Office Suite. Visual Basic Scripts (VBS) is the programming language used for...

  • How to Use the VBScript History Object

    Return the number of possible items in your history list with the VBScript history object. Use the object to quickly move items...

  • How to Create a Visual Basic Script

    The Visual Basic Scripting (VBScript) language provides you with the ability to manage desktop settings and applications. The language is written in...

  • How to Create VBS Files

    VBScript (Visual Basic Scripting Edition) is a scripting language developed by Microsoft. To create VBS files, you will need to use a...

  • How to Read the Contents of a Text File Using VBScript

    At times, when programming with VBScript, a programmer will need to read the contents of a text file. This can be accomplished...

  • What Is a VBS Worm?

    Visual basic script (VBS) worms are a prolific computer virus that infect individual computers and networks. These worms are created using the...

  • How to Hide a VBS Script

    Hiding VBS scripts on a Windows file system is a relatively easy task. There are a number of methods for hiding scripts...

  • How to Create VBS Login Scripts

    Login scripts are commonly used for mapping network drives, installing or setting a default printer, collecting computer system information, updating virus signatures...

Related Ads

Featured