You receive a security message when you try to access the Address Book programmatically by using the Outlook object model (329765)



The information in this article applies to:

  • Microsoft Outlook 2002

This article was previously published under Q329765

SYMPTOMS

If you try to gain access to the Address Book programmatically by using the Outlook object model when Outlook is not running, you may receive the following security prompt, even though Allow access to address book via Outlook object model is correctly enabled in the Outlook 10 Security Settings Folder.

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".

CAUSE

This behavior occurs because there is no running session of Outlook to determine the correct security profile to load. Therefore, the default security profile is used, causing the security prompt.

When you programmatically access an item in the Address Book, a session must be running to determine the correct security profile to load. When Microsoft Outlook 2002 is not running, the security dialog prompts the user because the default security profile is used.

WORKAROUND

To work around this issue, use the second code example in this section.

For example, this Visual Basic Scripting (VBS) Language code causes the security prompt to appear:
    Set ol      = CreateObject("Outlook.Application")
    Set AL      = ol.session.addresslists("Global Address List")
    Set AE      = AL.addressEntries(1)
    MsgBox AE.address
				

The following code works around the issue by causing a persistent reference to the established Outlook session, and therefore does not raise the security prompt:
    Set ol      = CreateObject("Outlook.Application")
    Set session = ol.session
    Set AL      = ol.session.addresslists("Global Address List")
    Set AE      = AL.addressEntries(1)
    MsgBox AE.address
				

MORE INFORMATION

For additional information about e-mail security features, click the article number below to view the article in the Microsoft Knowledge Base:

290499 OL2002: Administrator Information About E-Mail Security Features


Modification Type:MinorLast Reviewed:7/28/2006
Keywords:kbSecurity kbProgramming KbVBA kbfix kbprb KB329765