首页 > 解决方案 > 搜索已标记和未回复电子邮件的文件夹

问题描述

我正在寻找一种解决方案,它可以在 Outlook 中为我提供一个搜索文件夹,在那里我可以看到我标记的电子邮件,但我没有回复/转发。

我搜索了网络。我没有找到完整的解决方案,所以我将一个粘在一起并想分享。

我发现它非常有用,因为有时我会标记电子邮件以便稍后处理,但它会在其余标记的电子邮件之间丢失,我已经回复并标记了许多电子邮件,只是为了提醒自己我需要来自接受者。

此文件夹会自动搜索我真正需要回复的最重要的电子邮件。

标签: vbaoutlook

解决方案


这是我发现最适合我的方法:

Sub create_all_not_replied_emails_search_folder()

'not replied flagged emails search folder
'credits https://www.extendoffice.com/documents/outlook/5591-outlook-create-search-folder-for-unreplied.html for giving me the basic idea
'credits to https://stackoverflow.com/users/4539709/0m3r for giving me idea of how to get flagged emails as answer at https://stackoverflow.com/a/43772304/10010199

'delcaring variables so the code is cleaner and compatible with Option Explicit
Dim strScope As String 'variable for Outlook Folder that will be searched
Dim strRepliedProperty As String 'variable for first MAPI property
Dim strRepliedProperty2 As String 'variable for second MAPI property
Dim strFilter As String 'variable for the whole filter
Dim objSearch As Outlook.Search 'variable for the search folder

'Specify the folders to be searched, here it is default inbox
strScope = "'" & Application.Session.GetDefaultFolder(olFolderInbox).FolderPath & "'"


strRepliedProperty = "http://schemas.microsoft.com/mapi/proptag/0x10810003" 'Search filter for unreplied emails. With the parameters not 102 and not 103 will get unreplied and not-forwared emails
strRepliedProperty2 = "http://schemas.microsoft.com/mapi/proptag/0x10900003" 'Sear filter for flagged emails. With parameters not 0 (not flagged) and not 1 (not finished) we get emails that are flagged, but are not finished yet
strFilter = Chr(34) & strRepliedProperty & Chr(34) & " <> 102" & "AND" & Chr(34) & strRepliedProperty & Chr(34) & " <> 103" & "AND" & Chr(34) & strRepliedProperty2 & Chr(34) & " <> 0" & " AND " & Chr(34) & "http://schemas.microsoft.com/mapi/proptag/0x10900003" & Chr(34) & " <> 1" 'this is where the filter is set-up

Set objSearch = Outlook.Application.AdvancedSearch(Scope:=strScope, Filter:=strFilter, SearchSubFolders:=True, Tag:="SearchFolder") 'this is where the folder is created

'Save the search folder
objSearch.Save ("Not Replied Emails Dungeon") 'this is where the folder is saved with the name 'Not Replied Emails Dungeon'
MsgBox "Search folder is created successfully!", vbInformation + vbOKOnly, "Search Folder" 'Notify user that code finished

End Sub

推荐阅读