OL2000: How to Programmatically Change Contact Sensitivity in Outlook (255914)
The information in this article applies to:
This article was previously published under Q255914 SUMMARY
This article provides a code sample that shows how to programmatically change the sensitivity of Outlook contacts from private to normal. The code sample shows you how to use Microsoft Visual Basic Scripting Edition (VBScript) to perform this task.
REFERENCESFor additional information about creating solutions with Microsoft Outlook 97, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
166368 OL97: How to Get Help Programming with Outlook
146636 OL2000: Questions About Custom Forms and Outlook Solutions
The following steps create a custom Outlook form. When you open the form, it programmatically changes the sensitivity of each private contact to normal in a mailbox's default contact folder. To create this form:
- Open a new contact in Outlook. On the Tools menu, click Forms, and then click Design This Form.
- On the Form menu, click View Code. Type the following code into the VBScript code window of the form, and then close the editor:
Function Item_Open()
Dim iCount
MsgBox ("This macro will change the sensitivity of your contacts from Private to Normal")
Set olNS = Item.Application.GetNamespace("MAPI")
Set olContactsFolder = olNS.GetDefaultFolder(10)
Set olContacts = olContactsFolder.Items
iCount = 0
For Each olContact In olContacts
If olContact.Sensitivity = 2 Then
olContact.Sensitivity = 0
olContact.Save
iCount = iCount + 1
End If
Next
MsgBox "Number of contacts changed: " & CInt(iCount)
End Function
- On the Tools menu, point to Forms, and then click Publish Form. Save the form to the location you want.
You can also run the form. On the Form menu, click Run This Form.
Modification Type: | Major | Last Reviewed: | 9/29/2003 |
---|
Keywords: | kbhowto KB255914 |
---|
|