OL2000: How to Programmatically Change Contact Sensitivity in Outlook (255914)



The information in this article applies to:

  • Microsoft Outlook 2000

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.

MORE INFORMATION

Microsoft 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

REFERENCES

For 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:
  1. Open a new contact in Outlook. On the Tools menu, click Forms, and then click Design This Form.
  2. 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
    					
  3. 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:MajorLast Reviewed:9/29/2003
Keywords:kbhowto KB255914