Есть add-in для Outlook. В одной и той же функции 2 практически одинаковых куска кода работают по разному:
Dim col As Outlook.Items
strFilter = "[MessageClass] > 'IPM.Contacs' And [MessageClass] < 'IPM.Contacu' And [id] > '0'"
Set col = FindFolder.Items.Restrict(strFilter)
strFilter = "[MessageClass] > 'IPM.Contacs' And [MessageClass] < 'IPM.Contacu' And [id] = '" & id & "'"
Set col = FindFolder.Items.Restrict(strFilter)
В первом случае находит все объекты, у которых задан UserProperties["id"], а во втором случае, когда ищу по конкретному id, не находит ни одного объекта. Причем Err=0. Все проходит без ошибок. Кто-нибудь знает как с этим справиться?
Здравствуйте, Sick Boy, Вы писали:
SB>Есть add-in для Outlook. В одной и той же функции 2 практически одинаковых куска кода работают по разному:
SB>Dim col As Outlook.Items
SB>strFilter = "[MessageClass] > 'IPM.Contacs' And [MessageClass] < 'IPM.Contacu' And [id] > '0'"
SB>Set col = FindFolder.Items.Restrict(strFilter)
SB>strFilter = "[MessageClass] > 'IPM.Contacs' And [MessageClass] < 'IPM.Contacu' And [id] = '" & id & "'"
SB>Set col = FindFolder.Items.Restrict(strFilter)
SB>В первом случае находит все объекты, у которых задан UserProperties["id"], а во втором случае, когда ищу по конкретному id, не находит ни одного объекта. Причем Err=0. Все проходит без ошибок. Кто-нибудь знает как с этим справиться?
Проверил, всё работает пучком:
Set myItem = Application.CreateItem(olContactItem)
myItem.FullName = "Test"
Set myUserProperty = myItem.UserProperties.Add("id", olText, True)
myItem.UserProperties("id") = "777"
myItem.Save
Set FindFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
Set col = FindFolder.Items.Restrict("[MessageClass] > 'IPM.Contacs' And [MessageClass] < 'IPM.Contacu' And [id] = '" & 777 & "'")
If col.Count > 0 Then MsgBox col(1).FullName