1

I was wondering if there is something like a "Like" in VBA for Outlook 2003/2007 just like the LIKE in SQL...

For Example you have multiple users in a Network and everyone has another Mailbox name.

So i was thinking about something like this:

Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
Set TopFolder = olNs.Folders.Item("Mailbox - *") '<----- here i was thinking of something like a LIKE
Set SubFolder = TopFolder.Folders.Item("Projekte")
Set Folder = SubFolder.Folders

Thanks for Help

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
VanDeath
  • 519
  • 1
  • 7
  • 20

1 Answers1

4

There is a LIKE in VBA for string pattern matching, but to use in in your scenario you would need to iterate over the names of items in the olNs.Folders collection and compare them with your pattern;

if sFolderName like "Mailbox - *" then 
   Set TopFolder = olNs.Folders.Item(sFolderName) 
   exit for
   ...
Alex K.
  • 171,639
  • 30
  • 264
  • 288