Article ID: 181202 - Last Review: August 28, 2007 - Revision: 2.3 OL98: How to Automate Outlook from Another ProgramThis article was previously published under Q181202 On This PageSUMMARY
This article provides an overview of programming Microsoft Outlook 98 using
Automation from another program.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites: Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104) Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice) For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms) Automation (formerly OLE Automation) allows one program to control another program by either issuing commands or retrieving information programmatically. You can use the code examples in this article in Microsoft Word 97, Microsoft Excel 97, Microsoft Visual Basic, or any other program that supports Automation. Early vs. Late BindingYou can use either "early" or "late" binding to start an Automation session. Late binding uses either the GetObject or CreateObject function to initialize Outlook. For example, the following code sets an object to the Outlook program, which is the highest level object in the Outlook object model. All Automation code must first define an Outlook.Application object in order to access any of the other Outlook objects below that.
Once you reference the Outlook object library, you can use the following syntax to start an Outlook session: The Outlook Object ModelThe Outlook object model provides functionality to manipulate data stored in Outlook folders. However, there is limited functionality available to control Outlook itself. For example, you cannot use the object model to change the Options settings on the Tools menu.NOTE: As a possible workaround to limitations regarding the object model, you can use the CommandBars object provided by Microsoft Office to execute commands that are assigned to either toolbar buttons or menu commands. For example, you can use the CommandBars object to execute the New Call command (on the Dial submenu of the Tools menu) to bring up the New Call dialog box. For more information about using CommandsBars with Microsoft Outlook 98, please see the following article in the Microsoft Knowledge Base: 182394
(http://support.microsoft.com/kb/182394/EN-US/
)
OL98: How to Use Command Bars in Outlook Solutions
Most programming solutions need to interact with the data stored in
Outlook. Outlook stores all of its information in Messaging Application
Programming Interface (MAPI) folders. Therefore, after you set an object
variable to Outlook.Application, you will commonly set a "Namespace" object
to MAPI:
182614
(http://support.microsoft.com/kb/182614/EN-US/
)
OL98: Programming Examples for Referencing Items and Folders
Once you are programmatically at the folder that contains the items you
want to either use or create, you must use appropriate code to accomplish
your programming task. See the section below for some common programming
examples.
Sample Code for Common Programming TasksCreate a New Default Task Item:Resources for Outlook AutomationThe following list includes some important resources for automating Outlook, located on the Microsoft Outlook Developer Forum:
REFERENCES
For more information about creating solutions with Microsoft Outlook 98,
please see the following articles in the Microsoft Knowledge Base:
| Article Translations
|

Back to the top
