My junk mail folder has been filling up with messages composed in what appears to be the Cyrillic alphabet. If a message body or a message subject is in Cyrillic, I want to permanently delete it.
On my screen I see Cyrillic characters, but when I iterate through the messages in VBA within Outlook, the ‘Subject’ property of the message returns question marks.
How can I determine if the subject of the message is in Cyrillic characters?
(Note: I have examined the ‘InternetCodepage’ property – it’s usually Western European.)
The
Stringdatatype in VB/VBA can handle Unicode characters, but the IDE itself has trouble displaying them (hence the question marks).I wrote an
IsCyrillicfunction that might help you out. The function takes a singleStringargument and returnsTrueif the string contains at least one Cyrillic character. I tested this code with Outlook 2007 and it seems to work fine. To test it, I sent myself a few e-mails with Cyrillic text in the subject line and verified that my test code could correctly pick out those e-mails from among everything else in my Inbox.So, I actually have two code snippets:
IsCyrillicfunction. This can be copy-pasted into a new VBA module or added to the code you already have.Testroutine I wrote (in Outlook VBA) to test that the code actually works. It demonstrates how to use theIsCyrillicfunction.The Code
Example Usage