HOWTO: Performing OLE Automation with Visual Basic Script 1.0

ID: Q165673


The information in this article applies to:
  • Microsoft Visual Basic, Scripting Edition, version 1.0


SUMMARY

Visual Basic Scripting Edition (VBScript) version 1.0 does not support the CreateObject function that is available in Visual Basic for Applications (VBA). The HTML object tag can be used in conjunction with Visual Basic Scripting to automate any OLE Automation server.

NOTE: VBScript 2.0 (and higher) now supports the CreateObject function. However, this version does not ship with the current version of Internet Explorer 3.0. For more information on obtaining the latest version of VBScript, see the following Web site:

http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/


MORE INFORMATION

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

The following example demonstrates how the HTML object tag and Visual Basic Scripting can be used to send a message with the OLE Messaging Automation Object.

NOTE: Replace objOneRecip.Name = "Some Name" with a valid recipient name:


<HTML>
<HEAD>
<TITLE>Sample Script to Send a MessagePage</TITLE>
</HEAD>
<BODY>
   <OBJECT ID="MAPI" WIDTH=10 HEIGHT=10
    CLASSID="CLSID:3FA7DEB3-6438-101B-ACC1-00AA00423326">
  </OBJECT>

<SCRIPT LANGUAGE="VBScript">
Dim oSession, objMessage, objOneRecip
MAPI.Logon
Set objMessage = MAPI.Outbox.Messages.Add
Set objOneRecip = objMessage.Recipients.Add
    objOneRecip.Name = "Some Name"
    objOneRecip.Type = 1
    objOneRecip.Resolve 1
objMessage.subject = "Test MAPI/OLE VB Message w/ole object - explicit"
objMessage.Text = "Like you really wanted this.. Please Delete this
test"
objMessage.Send 0,0,0

</SCRIPT>
</BODY>
</HTML> 

Additional query words: KbsweptIE5000 May-03-1999

Keywords : kbcode kbinterop kbActMsg OleMsg
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: July 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.