在 Outlook 文件夹中搜索文件夹:MULTIPLE OUTCOMES [英] Searching for a folder in outlook folders: MULTIPLE OUTCOMES
问题描述
我想选择一个特定的邮箱(收件箱、存档邮箱等)并按名称查找特定的文件夹.
I would like to choose a particular mailbox (inbox, archive mailbox, etc.) and find a particular folder by name.
我想要一个选项,它不会只显示一个结果,但如果在特定收件箱中有两个相同的子文件夹,将显示第一个,如果我接受它,则关闭案例,否则我可以转到下一个结果.
I would like to have the option which will not show me only one result but if in a particular inbox there will be two same subfolders, will show me the first one, if I accept it than case closed, if not I can go to the next result.
Private MyFolder As Outlook.MAPIFolder
Private MyFolderWild As Boolean
Private MyFind As String
Public Sub FindFolder()
Dim Name$
Dim Folders As Outlook.Folders
Set MyFolder = Nothing
MyFind = ""
MyFolderWild = False
Name = InputBox("Enter the Folder Name that you would like to find:" + vbCrLf + vbCrLf)
If Len(Trim$(Name)) = 0 Then Exit Sub
MyFind = Name
MyFind = LCase$(MyFind)
MyFind = Replace(MyFind, "%", "*")
MyFolderWild = (InStr(MyFind, "*"))
Set Folders = Application.Session.Folders
LoopFolders Folders
If Not MyFolder Is Nothing Then
If MsgBox("Do you want to go to this folder ?" & vbCrLf & MyFolder.FolderPath, vbQuestion Or vbYesNo, "TheTechieguy.com - Found your Folder:") = vbYes Then
Set Application.ActiveExplorer.CurrentFolder = MyFolder
End If
Else
MsgBox "The folder you were looking for can not be found.", vbCritical, "TheTechieguy.com - Folder NOT found:"
End If
End Sub
Private Sub LoopFolders(Folders As Outlook.Folders)
Dim F As Outlook.MAPIFolder
Dim Found As Boolean
For Each F In Folders
If MyFolderWild Then
Found = (LCase$(F.Name) Like MyFind)
Else
Found = (LCase$(F.Name) = MyFind)
End If
If Found Then
Set MyFolder = F
Exit For
Else
LoopFolders F.Folders
If Not MyFolder Is Nothing Then Exit For
End If
Next
End Sub
总结:如果脚本能够在特定的收件箱或功能邮箱中找到特定的文件夹,我将指出并显示符合条件的每个结果,那就足够了.
Sum up: It will be good enough if script will find particular folder in particular inbox or functional mailbox, which I will point, and show every result which matches the criteria.
推荐答案
要选择文件夹,请使用 Pickfolder.http://msdn.microsoft.com/en-us/library/office/ff869969%28v=office.15%29.aspx
To select a folder use Pickfolder. http://msdn.microsoft.com/en-us/library/office/ff869969%28v=office.15%29.aspx
在离开 LoopFolders 之前确认找到了正确的文件夹,而不是之后.
Confirm the correct folder was found before leaving LoopFolders, not after.
将测试移到 LoopFolders 中并测试 F.
Move the test inside LoopFolders and test F.
If MsgBox("Do you want to go to this folder ?" & vbCrLf & _
F.FolderPath, vbQuestion Or vbYesNo, _
"TheTechieguy.com - Found your Folder:") = vbNo Then
Found = False
End If
If Found Then
这篇关于在 Outlook 文件夹中搜索文件夹:MULTIPLE OUTCOMES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!