开发者

Like item in VBA?

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

For Exampl开发者_如何学JAVAe 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


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
   ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜