Detecting Conflicts in VB Code

G

Guest

Does anyone know how I can prevent conflicted contact items from being included in the Items collection returned by a "restrict" method of the items collection

I currently using

Dim sFolderPath As String ' Complete path of Outlook folde
Dim sRestrict As Strin
Dim oFolder As MAPIFolder ' Outlook folder objec
Dim oContacts As Items ' Collection of items in Outlook folde
Dim oContact As ContactItem ' Single Outlook contact ite

sRestrict = "[RelationshipType] = 'Group/Meetings' AND [ItemStatus] <> 'Moved'
Set oContacts = oFolder.Items.Restrict(sRestrict
If oContacts.Count > 0 The
For Each oContact In oContact
' do my stuff her
Nex
End I

When the code tries to set oContact to an Item with a conflict, it creates a "type mismatch" error.

How do I prevent this?
 
S

Sue Mosher [MVP-Outlook]

Your code should work if you Dim Contact as Object.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Jeff Moore said:
Does anyone know how I can prevent conflicted contact items from being
included in the Items collection returned by a "restrict" method of the
items collection?
I currently using:

Dim sFolderPath As String ' Complete path of Outlook folder
Dim sRestrict As String
Dim oFolder As MAPIFolder ' Outlook folder object
Dim oContacts As Items ' Collection of items in Outlook folder
Dim oContact As ContactItem ' Single Outlook contact item

sRestrict = "[RelationshipType] = 'Group/Meetings' AND [ItemStatus] <> 'Moved'"
Set oContacts = oFolder.Items.Restrict(sRestrict)
If oContacts.Count > 0 Then
For Each oContact In oContacts
' do my stuff here
Next
End If

When the code tries to set oContact to an Item with a conflict, it
creates a "type mismatch" error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top