MORE INFORMATION
Resources
There are a variety of resources that are available to help you
develop Outlook solutions.
For additional information about where to find these
resources, click the article number below to view the article in the Microsoft
Knowledge Base:
287531 OL2002: Resources for Custom Forms and Programming
Outlook Security Features
Microsoft Outlook 2002 includes various features designed to
prevent the spread of viruses transmitted via e-mail. When using the Outlook
object model and other developer-oriented features, you may encounter
unexpected or unwanted behavior, typically one of the following
warnings:
A program is trying to automatically
send e-mail on your behalf.
Do you want to allow this?
If this
is unexpected, it may be a virus and you should choose "No".
-OR-
A program is trying to access e-mail addresses you have
stored in Outlook. Do you want to allow this?
If this is unexpected,
it may be a virus and you should choose "No".
If the user clicks no,
the following error will occur:
Run-time error
'287':
Application-defined or object-defined error
For more information about these warnings, the new object model security features that are
included with Outlook 2002, and information about how to avoid these features
when designing a solution, click the following article number to view the article in the Microsoft Knowledge Base:
290500
Description of the developer-related e-mail security features in Outlook 2002
Items and Outlook Custom Forms
Q1: I have created a custom Outlook form, but it is not used when I create a new item or when I open an existing item that I had before I created the form. Why is my form not used?A1: To use a custom Outlook form in a typical folder-based form
solution, there are three steps that you need to complete:
- Publish the form in the folder or forms library where you
want to use it. On the Tools menu in the custom form, point to Forms, and then click Publish Form. The name of the form is also the Message Class, which is important for the next two steps. If you are not sure
where to publish the form, click the article number below to view the article
in the Microsoft Knowledge Base:
290802 OL2002: How to Determine Where to Publish a Form
- Make this new form the default form for that folder. To do
this, right-click the folder, and then click Properties. In the When posting to this folder box, click
your custom form, and then click OK. New items that you create will then use the custom form instead
of the default Outlook form.
- If you have any existing items in the folder that you want
to use this new form, change the Message Class field in each of the items in the folder. The Message Class field of an item tells Outlook which form to use to display the
item. You cannot directly change this field in Outlook because it is considered
read-only, but you can use programming code and the Outlook object model to
change the message class of the field.
For additional information about how
to change the message class of items in a folder and utilities to help you do
this, click the article number below to view the article in the Microsoft
Knowledge Base:
290659 OL2002: How to Update Existing Items to Use a New Custom Form
Q2: How can I disable the macro warning message when someone opens an item?A2: If the form is not located in a trusted location, such as the
Organizational Forms Library on an Exchange Server-based computer, Outlook
displays the macro warning message to protect you from potentially malicious
programming code, commonly called macro viruses. You cannot directly prevent
the warning message from appearing; you must publish the form to a trusted
location. For additional information about this issue
and other reasons why you may receive this warning message, click the following
article number to view the article in the Microsoft Knowledge Base:
290663
Outlook does not run VBScript code when you open an item
Q3: I created a custom form, but when I close and then open the item again, or when I send the form to someone else, all of the information that I entered into my custom controls is gone. Why does this happen?A3: In Outlook, controls on a form are used to display information,
but the information is actually stored in fields. Therefore, for the values of
the controls to be preserved, the control must be bound to an Outlook standard
or user-defined field.
For additional information about this issue, click the article
number below to view the article in the Microsoft Knowledge Base:
290655 OL2002: Overview of Using Fields and Controls on Custom Forms
Q4: User-defined fields are not working the way that I expect them to work. Why?A4: User-defined fields offer flexibility in how data is structured
within a folder, but this flexibility can also provide some challenges for
solution developers. For
additional information about how to use user-defined fields in Outlook, click
the following article number to view the article in the Microsoft Knowledge
Base:
290656
How to work with user-defined fields in solutions in Outlook 2002
Q5: Why do some items in a folder have different icons? Why do some items in a folder have an abnormally large size? Why does the Message Class of an item change back to the default Message Class? How can I better understand how forms work in Outlook?A5: Understanding the difference between forms and items and how the
two relate to each other is important when you design an Outlook solution. In
most scenarios, forms are published to a location and then linked to the items
in the folder. However, you can store the forms in individual items, and this
can cause the behavior of Outlook to change in many ways. For additional information about form definitions and how they
relate to items, click the following article number to view the article in the
Microsoft Knowledge Base:
290657
Description of form definitions and one-off forms in Outlook 2002
Q6: When I import or export contacts from an external database, how can I map some of the fields to the user-defined fields that I have set up in a custom form?A6: This is a limitation of the Outlook Import and Export Wizard.
There is no way to directly import or export data into user-defined fields. If
you are familiar with Visual Basic programming, you can create a solution that
programmatically imports or exports the information.
For additional information about this
issue and examples of how to import or export user-defined fields, click the
article numbers below to view the articles in the Microsoft Knowledge Base:
197654 OL2000: Cannot Import or Export User-Defined Contact Fields
290658 OL2002: How to Programmatically Import Outlook Items from Microsoft Access
290792 OL2002: How to Programmatically Export Outlook Items to Microsoft Access
Q7: When I use a control on a custom Outlook form, why do none of the control events appear to work?A7: When you use a custom Outlook form, Outlook only supports the
Click event for controls. Many controls are specifically designed to
work with other events, and because these events are not supported by Outlook,
the controls may not function in Outlook.
To work around this
limitation, you can create a Visual Basic ActiveX component (formally called an
OLE server application). You can start the component by using the
CreateObject method in VBScript. The component can display a Visual Basic form
with the appropriate controls, receive the information that the user selects or
types, and then automate Outlook to send any necessary information back to the
Outlook form.
This technique involves many aspects of programming.
For information about how to create an ActiveX component, see the documentation
for Microsoft Visual Basic.
For
additional information about control events on Outlook custom forms, click the
article number below to view the article in the Microsoft Knowledge Base:
290660 OL2002: Click Event Behavior for Standard Controls
Q8: Can I print forms as they appear on the screen?A8: There is no direct way to print forms as they appear on the
screen. Also, the Outlook object model does not provide more printing
functionality than that which is provided by Outlook itself. To work around
this limitation, you can either use another program to print Outlook
information, or you can download a ActiveX control or Outlook extension to
create a custom form printing solution. For additional
information about how to create custom form printing solutions, click the
following article number to view the article in the Microsoft Knowledge Base:
290775
Outlook 2002 doesn't print forms as expected
Q9: Can I design a form in Outlook 2002 and use it with previous versions of Outlook?A9: This is generally not a good idea. To help ensure compatibility,
design the form by using the earliest version of Outlook that uses the form. For additional information about designing forms to use
with more than one version of Outlook, click the following article number to
view the article in the Microsoft Knowledge Base:
291172
Description of designing custom forms for different versions of Outlook
Q10: How can I get option buttons to work on an Outlook form?A10: You need to follow specific steps in order for option buttons to
function in Outlook.
For additional information about how option
buttons work, click the article number below to view the article in the
Microsoft Knowledge Base:
290652 OL2002: How to Use Option Buttons on an Outlook Form
Q11: What is the forms cache? Why does Outlook use it? How does it work?A11: The forms cache is an integral part of how Outlook works with
forms. As a forms developer, it is important to have a general understanding
about how the forms cache works so that you can troubleshoot potential issues
that may occur. For additional information about the forms cache, click the
following article numbers to view the articles in the Microsoft Knowledge Base:
290806
Description of Outlook 2002 forms cache
291183 How to troubleshoot Outlook forms cache issues
Q12: How can I manipulate the Message or Notes field on a form?A12: If your mail format is set to Outlook Rich Text format, Outlook
provides limited support for manipulating the body of a message. However, if
you use Hypertext Markup Language (HTML) format or Microsoft Word as your
e-mail editor, you can create highly formatted e-mail messages.
For additional information about working
with the body of an item, click the article number below to view the article in
the Microsoft Knowledge Base:
291153 OL2002: Working With the Message or Body of an Outlook Item
Q13: There are many steps to open a form from the Organizational Forms Library or Personal Forms Library. How can I add a form to a toolbar button to make this easier?A13: You need to create custom Visual Basic for Applications code or
a COM add-in to do this.
For
additional information about how to do this, click the article number below to
view the article in the Microsoft Knowledge Base:
290803 OL2002: How to Open a Form from a Toolbar Button
Q14: How can I start another program or display a Web page from an Outlook form?A14: You can use the
CreateObject method in VBScript to automate a program as long as the program
support automation.
For additional information about this
issue, click the article numbers below to view the articles in the Microsoft
Knowledge Base:
292009 OL2002: How to Start Another Program from an Outlook Form
294865 OL2002: How to Display a Web Page in an Outlook Form
Visual Basic for Applications, COM Add-ins, and Automation
Q1: What is the difference between VBScript and Visual Basic for Applications, and which one should I use?A1: Outlook custom forms use Visual Basic Scripting Edition
(VBScript) as they did in previous versions of Outlook. However, Outlook also
provides support for Visual Basic for Applications at the application level,
meaning that you can run macros from the main Outlook toolbars or menus and
that code can function outside of the scope of an item. Most of the recent
additions to the Outlook object model were added to support this new
application-level programming model. For example, there are events that enable
custom code to run when certain things happen in Outlook, such as when you
receive new mail, or if the user clicks a different item in a folder. Your code
can also run much like a batch process, where you click a toolbar button and a
macro retrieves data from a folder and then updates information in a public
folder.
Q2: Visual Basic for Applications and COM add-ins both give me the ability to create program-level code. Which one should I use?A2: Visual Basic for Applications in Outlook was designed primarily
to create personal solutions. The main advantage to using Visual Basic for
Applications is that you can quickly create a solution to fit your needs. COM
add-ins are typically the better choice if you want to distribute your
solution. However, COM add-ins generally require a greater investment in
development time. Also, if you need to develop a COM add-in, it is often easier
to develop and debug the solution by using Visual Basic for Applications. Then,
when the Visual Basic for Applications code is functioning as you want it to,
you can typically move the code into the COM add-in framework with very few
changes.
Q3: How can I record macros?A3: Although Outlook now includes Visual Basic for Applications, the
Outlook object model does not provide functionality that supports recording
macros.
For additional information about not being able to record
macros, click the article number below to view the article in the Microsoft
Knowledge Base:
291417 OL2002: Unable to Record Macros in Outlook
Q4: How can I get started integrating Outlook into another program?A4: You can use automation to programmatically control Outlook from
another custom program. For additional information about automating
Outlook, click the following article number to view the article in the
Microsoft Knowledge Base:
291120
How to automate Outlook 2002 from another program
Q5: Where is my Visual Basic for Applications project stored? How can I distribute a solution that I created to other people?A5: Outlook Visual Basic for Applications code is stored in a single
file called VBAProject.OTM, and Outlook Visual Basic for Applications is not
designed to be distributed. For additional information about how to
use Visual Basic for Applications projects in Outlook, click the following
article numbers to view the articles in the Microsoft Knowledge Base:
290779
Description of managing and distributing Outlook 2002 Visual Basic for Applications (VBA) projects
290780 OL2002: Code Does Not Work After You Distribute a VBA Project
Q6: How can I get started developing a COM add-in?A6:
For additional information about how to develop COM
add-ins, click the article number below to view the article in the Microsoft
Knowledge Base:
291163 OL2002: How to Create a COM Add-in for Outlook
Q7: My COM add-in causes Outlook to stop responding (hang). What could be wrong?A7: Your COM add-in may be causing a Visual Basic run-time error to
occur, and this may be causing a problem with Outlook. Because of this
limitation of COM add-ins, use error trapping throughout your COM add-in code
to trap any potential run-time errors.
For
additional information about this issue, click the article number below to view
the article in the Microsoft Knowledge Base:
291166 OL2002: All COM Add-in Run-Time Errors Must Be Trapped
Q8: My COM add-in causes Outlook to not quit. What could be wrong?A8: Your COM add-in is most likely not releasing
Explorer or
Inspector objects, and this causes Outlook to not quit.
For additional information on this issue, click the article
number below to view the article in the Microsoft Knowledge Base:
294867 OL2002: You Cannot Fully Quit Outlook When You Use a COM Add-in
The Object Model and Other General Questions
Q1: Before I start to develop a solution, how can I find out if someone has already developed something that I am planning?A1: The Slipstick Systems Web site provides a comprehensive summary
of add-ins and utilities. For more information about these add-ins, view the
following Slipstick Web site:
The
third-party products that are discussed in this article are manufactured by
companies that are independent of Microsoft. Microsoft makes no warranty,
implied or otherwise, regarding the performance or reliability of these
products.
Q2: How can I programmatically refer to a particular Outlook folder or a particular item? How can I create a new folder or item?A2: Outlook provides many ways to programmatically access and
manipulate items and folders.
For additional information about how
to work with folders and items, click the article number below to view the
article in the Microsoft Knowledge Base:
290804 OL2002: Programming Examples for Referencing Items and Folders
Q3: Why can I not figure out how to do something? Is it possible?A3: Outlook does not support a full object model, such as those in
Word or Microsoft Excel, so what you are trying to do may not be possible.
Also, there may be other Outlook design considerations or limitations that may
prevent you from using the approach that you want to create a solution.
For
additional information about this, click the article number below to view the
article in the Microsoft Knowledge Base:
294868 OL2002: Custom Forms and Programming Limitations
Q4: How can I programmatically search for items and folders based on the contents of a field?A4: You cannot programmatically use the Find or Advanced Find
features in Outlook, but you can use the
Find method in the Outlook object model to retrieve a single item
based on the contents of one or more fields. You can also use the
Restrict method to retrieve a set of items that match certain criteria.
For additional information about how to use the Find
and Restrict methods, click the article number below to view the article in the
Microsoft Knowledge Base:
291161 OL2002: Using Find and Restrict to Retrieve Items
Q5: I am having problems working with a collection of objects, what is the cause of this problem?A5: There are three common scenarios that Outlook developers have
problems with when they work with collections in the Outlook object model.
Because collections, especially the Items collection, are in integral part of
the Outlook object model, you should be familiar with these issues.
For additional information about how to
avoid potential problems when you use collections, click the article numbers
below to view the articles in the Microsoft Knowledge Base:
292457 OL2002: How to Properly Reference Members of a Collection
292062 OL2002: How to Handle Unexpected Items in a Collection
292459 OL2002: How to Delete Items in a Collection
Q6: How can I generate reports based on data that is stored in Outlook?A6: There are a few approaches that you can take:
- Import the data into another program and use that program's
report generating capabilities. Microsoft Access is typically the best program
to use because you can use the Link Exchange/Outlook Wizard in Access. However,
this wizard does not support user-defined Outlook fields and some of the
Outlook standard fields. If you require additional fields that the wizard does
not support, you must create custom code to transfer the data from an Outlook
folder into an Access table.
- Automate another program from Outlook to generate a report.
You can do this by using VBScript in an Outlook form, Visual Basic for
Applications, or a COM add-in.
- Use a third-party tool to generate reports. One available
utility is Crystal Decisions Crystal Reports. For more information about this
utility, view the following Crystal Decisions Web site:http://www.crystaldecisions.net/products/crystalreports/default.asp
Q7: What is the best way to create a routing or workflow solution in Outlook?A7: Creating a custom Outlook form solution is typically not the
best approach to implement a routing or workflow solution. If you are not
familiar with designing custom Outlook forms, implementing this type of
solution is often more complex than it appears.
For additional information about what to consider if you
want to implement a routing solution, click the article number below to view
the article in the Microsoft Knowledge Base:
291122 OL2002: Overview of Implementing Workflow or Routing Solutions
Q8: How can I integrate address books with my solution?A8: The Outlook object model does not provide a way to display an
address book dialog box, but you can access most address book information. If
you require more functionality that the Outlook object model provides, the
Collaboration Data Objects (CDO) object model most likely provides the
functionality that you require.
For additional information about how to work with
address books in a custom solution, click the article number below to view the
article in the Microsoft Knowledge Base:
291147 OL2002: Using Address Books in an Outlook Solution