none
Items.Restrict fails to match some Hebrew strings RRS feed

  • Question

  • hi

    While trying to Find or Restrict mail items by the mailitem subject, some items were returned successfuly while other failed.

    (i'm programing Outlook 2013 vba)

    those who failed contained mixed hebrew & english text i.e. "קובץ.xlsx"

    i got runtime error 440, "Illegal Condition" 

    since the condition contained that mixed text

    is there a way to make it work?

    thanks

    Reuven

    Tuesday, February 4, 2014 4:16 PM

Answers

All replies

  • Hello Reuven,

    What search criteria do you use for the Find or Restrict methods?

    The format of the string depends on the field type that you are going to filter by. Please note that there are some item properties that you can’t use for the filter. You can read more about the properties not allowed in the filter string and string formats used for the search criterion on MSDN.

    You may find the How To: Use Restrict method to retrieve Outlook mail items from a folder and How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder articles helpful.


    Tuesday, February 4, 2014 4:34 PM
  • Are you sure you the condition is correctly built?

    I had no problem with the following script executed from OutlookSpy (click Script, paste the script, click Run)

    set Drafts = Application.Session.GetDefaultFolder(olFolderDrafts)
    set Item = Drafts.Items.Add
    Item.Subject = "קובץ.xlsx"
    Item.Save
    set FoundItem = Drafts.Items.Find("[Subject] = ""קובץ.xlsx"" ")
    MsgBox FoundItem.Subject
    


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, February 4, 2014 5:55 PM
  • Thank you Eugene

    i'm trying to filter by the "Subject" property

    the program works for some mail items but fails when the subject of a specific mail item is an hebrew filename + extension (like "קובץ.doc")

    i assume that the error message is caused by the processed data which always were of the same type  ("קובץ.doc")

    here is the code

    ("It" is a valid mail item (item.class=olmail)

                    If It.Subject <> "" Then
                        cond3 = "[Subject]= " & It.Subject ' & Chr(34)
                        Set MyDups = mySubFolder.Items.Restrict(cond3)
                        ' do something with MyDups
                     End If ' no subject

    any idea?

    regards

    reuven

    Thursday, February 20, 2014 2:11 PM
  • Thank you Dmitry 

    i'm trying to filter by the "Subject" property

    the program works for some mail items but fails when the subject of a specific mail item is an hebrew filename + extension (like "קובץ.doc")

    i assume that the error message is caused by the processed data which always were of the same type  ("קובץ.doc")

    here is the code

    ("It" is a valid mail item (item.class=olmail)

                    If It.Subject <> "" Then
                        cond3 = "[Subject]= " & It.Subject ' & Chr(34)
                        Set MyDups = mySubFolder.Items.Restrict(cond3)
                        ' do something with MyDups
                     End If ' no subject

    any idea?

    regards

    reuven

    Thursday, February 20, 2014 2:12 PM
  • Does my sample script work for you?

    Are you sure you have the subject right?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, February 20, 2014 2:45 PM
  • Hello Reuven,

    Did you try to specify a hebrew string as a condition in the following way:

    cond3 = "[Subject]= 'קובץ.doc'"
    Does it work?
    Friday, February 21, 2014 8:23 PM
  • Hello Eugene

    after insertion single quates(') it works

                            cond3 = "[Subject]= " & "'" & It.Subject & "'"

    thank you

    reuven

    Sunday, February 23, 2014 7:39 AM
  • Good news, Reuven!

    Thank you for letting me know the cause of the issue.

    Sunday, February 23, 2014 9:51 AM