Search message, then (1) Jump to folder & (2) Select message that you searched for

mail11

Senior Member
Outlook version
Email Account
IMAP
Operating system::    Windows 10
Outlook version:     365
Email type or host:    Microsoft Exchange

I was using this code a while ago, I'm not sure if it was from this forum.

It can do:
(1) Jump to folder

But also would like it to do:
(2) Select message that you searched for
Reason is that there can be a lot of emails in a folder.

Code:
Option Explicit
Public Sub get_folder_path()
    Dim my_object As Object
    Dim my_folder As Outlook.MAPIFolder
    Dim MyMessage$
    Set my_object = Application.ActiveWindow
    If TypeOf my_object Is Outlook.Inspector Then
        Set my_object = my_object.CurrentItem
    Else
        Set my_object = my_object.Selection(1)
    End If
    Set my_folder = my_object.Parent
    MyMessage = "Path:" & vbCrLf & my_folder.FolderPath & vbCrLf & vbCrLf
    MyMessage = MyMessage & "Switch to folder?"
    If MsgBox(MyMessage, vbYesNo) = vbYes Then
        Set Application.ActiveExplorer.CurrentFolder = my_folder
    End If
End Sub
 
It was probably from Michael Bauer of vboffice.net. He was active here for awhile but it is also on his site.

If you get the message's entryid when you set my_object you could use the to find the message after you open the folder. I'll test some code.

Or... you could set a category on the message so its easier to find the folder.

After end if where my_object is set
my_object.categories = "category name" ' category need to exist in the master list to have a color assigned)
my_object.save
 
Thanks Diane, the first option sounds good, I presume this is go to the folder and find the message in that folder, which is what I'm trying to do but don't know how to do it.
 
Hi Diane, did you test the code as mentioned in your previous response?
 
No, I didn't have time. My kids came for Easter and the grands slept in my office. I'll try and work on it tomorrow.
 
Similar threads
Thread starter Title Forum Replies Date
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
J Outlook 2016 After a search in all mailboxes, where is each message that was found? Using Outlook 6
J Message search and edit, another way? Outlook VBA and Custom Forms 4
S Create A Search Folder That Looks For Message Class? Outlook VBA and Custom Forms 0
B Search: Cannot find which Folder Contains a Message Using Outlook 3
E Search for folder by key in subject then move new message to related folder Outlook VBA and Custom Forms 1
H Search and delete part of a link inside HTML body message Outlook VBA and Custom Forms 2
H Using Outlook Rules to search for NewLines in message body Using Outlook 1
C Odd error message not found in Google search Using Outlook 1
A Outlook 2007 message search results loses focus Using Outlook 7
G Search Folders and Jump to Folder Outlook VBA and Custom Forms 2
A 'search people' now asks me to 'press enter' Using Outlook 11
A Relocate Search Bar in Outlook Using Outlook 2
A Search folder and move the email Outlook VBA and Custom Forms 0
farrissf Outlook 2016 Optimizing Email Searches in Outlook 2016: Seeking Insights on Quick Search vs Advanced Search Features Using Outlook 0
C Advanced search terms for "Outlook Data File" Using Outlook 1
T How to find or display the sub-folder name for an Archive Search Using Outlook 10
P Search folder: all emails sent to or from a domain Using Outlook 1
T Outlook365 search item listed as "potential matches" can't be opened Using Outlook 0
Victor_50 Outlook 2019 Jump to folder from search folder Outlook VBA and Custom Forms 0
Witzker Outlook 2019 Macro GoTo user defined search folder Outlook VBA and Custom Forms 6
J Outlook search bar in Office 2021 Professional Using Outlook 1
T Outlook 365 Search Box reverting to old location Using Outlook 2
P Outlook 2013 search no longer works Using Outlook 2
C How to search for items in Outbox with multiple accounts? Using Outlook 20
J search doesn't find anything Using Outlook 1
kkqq1122 How would I add Search for attachment name Outlook VBA and Custom Forms 3
A Any way to force sort by/group by on search results with VBA? Outlook VBA and Custom Forms 1
B Search and Find Email by Folder Name Outlook VBA and Custom Forms 2
C Search not accurate, but not indexing Using Outlook 9
J How do you disable address search box when typing @ in body of email? Using Outlook 0
H Outlook 2019 intermittent search results Using Outlook 0
D Create advanced search (email) via VBA with LONG QUERY (>1024 char) Outlook VBA and Custom Forms 2
D Advanced e-Mail search on from/to contact group only searches for first 20 contacts in group Using Outlook 0
mll persistently customise columns in outlook advanced search Using Outlook 3
S vba outlook search string with special characters Outlook VBA and Custom Forms 1
S VBA search string with special characters Outlook VBA and Custom Forms 1
H Search Email Header for Content Type Outlook VBA and Custom Forms 1
P Posts in Folder No Longer Group by Conversation Column After Search Using Outlook 0
O Advanced search - can I use booleans Using Outlook 3
Y Filter unread emails in a search folder vba help Outlook VBA and Custom Forms 0
M Reverting The Outlook Search Box Location (or other undesired additions) Using Outlook 1
M Something went wrong and your search couldn't be completed Using Outlook 1
M Disable Contact Card Results when using "Search People" in Outlook Ribbon Using Outlook 7
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
P outlook 2008 search box criteria couldn't be saved Using Outlook 2
C Outlook with Office365 - search across account, by date rate, in multiple folders - how? Using Outlook 2
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
L New Location for the Search Bar Using Outlook 6
T How can you include Junk Email in Search Results like you can include Deleted Items? Using Outlook 3

Similar threads

Back
Top