Jump to Inbox folder when click on Favorite

Fred Dagg

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
There are a couple of older threads looking for this (inluding my own posted 4 years ago), but can't post to those now.

I came up with a solution that is good enough for me on this. It requires some vba that autocreates a dummy subfolder under the folder your favorite points to. Then we can jump to that and be right below the real folder.

Open Outlook vba (Shift F11) and pste these two procs in there somewhere.
Create a Quick Access Toolbar entry that points to macro JumpToFavorite.
Click on any folder in Favorites then click on the quick access button. Voila.

'
' Can jump to full path of a folder but if its a fav, it only jumps within Favs list
' So we create a dummy subfolder and jump to that
'
Sub JumpToFavorite()

Dim strUNC As String
Dim oFld As Outlook.Folder

On Error Resume Next
strUNC = ActiveExplorer.CurrentFolder.FolderPath
Set oFld = lib_FolderObjectFromPath(strUNC)
Set ActiveExplorer.CurrentFolder = oFld.Folders("jumpto")
If Err <> 0 Then
Set oFld = oFld.Folders.Add("jumpto")
Set ActiveExplorer.CurrentFolder = oFld
End If
Set oFld = Nothing

End Sub

'
' Return a folder object after passing a full path eg. from objFolder.FolderPath
'
Function lib_FolderObjectFromPath(pstrSrcFolder As String) As Outlook.Folder

Dim oNS As Outlook.NameSpace
Dim oFolder As Outlook.Folder
Dim oParFolder As Outlook.Folder
Dim strParts() As String
Dim intCnt1 As Integer

Set oNS = GetNamespace("MAPI")
strParts = Split(Mid(pstrSrcFolder, 3), "\")
Set oParFolder = oNS.Folders(strParts(0))

For intCnt1 = 1 To UBound(strParts)
Set oFolder = Nothing
On Error Resume Next
Set oFolder = oParFolder.Folders(strParts(intCnt1))
On Error GoTo 0
If oFolder Is Nothing Then
Set lib_FolderObjectFromPath = oFolder
Exit Function
End If
Set oParFolder = oFolder
Next intCnt1

Set lib_FolderObjectFromPath = oFolder
Set oFolder = Nothing
Set oParFolder = Nothing
Set oNS = Nothing

End Function
 

Fred Dagg

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
I had thought I could use SendKeys "{Up}" to get it jump up to the real folder but the navigation pane isn't the active pane after running the code above so keystrokes don't work.
Tried ActiveExplorer.Activate but that doesn't solve it.
Also you can't just use Set ActiveExplorer.CurrentFolder = oFld.Parent as that takes you back to Favorites pane.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You want to jump to the folder in the Folder list when you select the folder in the Favorites?


I don't know if you borrowed any of this code - but it should work - pass the folder name to it and have it open the folder.
 

Fred Dagg

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Thanks Diane but that code suffers the same problem. If you give it a folder name that is in your Favorites it will take you to Favorites and select that folder. But it still won't take you to that folder within the full tree of folders.

Lets say I have a folder called Customers and under that are folders for each Customer. If an email comes in from Fred and I want to drag it to Customers\Fred I have to navigate manually to the Customers folder in the tree, then find Fred, so I can drag/drop the email. I can't add every customer to Favorites so the idea is to add Customers to Favorites. Then if I select Customers in Favorites I want the folder tree to open up to Customers, so I just scroll down to Fred.

So in this example, I could use that code and type in Fred and it would work (assuming I don't have another folder called Something\Fred that gets found first). But what about customer The Very Little Bottling Co. Yes I could use wildcards but thats still hard work if I have another customer called The Very Little Bottling Org. I'd have to type out 'A Very Little Bottling%'. Phew!

Much simpler would be a Fav called Customers then have it jump to Customers and I scroll from there.
And that's where my code finally gets close, though with the nuisance of creating the dummy subfolder.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
What I was thinking (on the VBoffice code) - use it to expand a folder in the folder list - could be your jumpto or any existing folder in the path. it does the same thing your code does - I don't know which would be faster....

If the folder names match the From display name or the email address, it would work too.


Code:
' orginial code: http://vboffice.net/en/developers/find-folder-by-name
Private m_Folder As Outlook.MAPIFolder
Private m_Find As String

Private Const SpeedUp As Boolean = True

Public Sub FindFolder()
  Dim Name$
  Dim Folders As Outlook.Folders

' use an existing subfolder here
  m_Find = "Test"

  m_Find = LCase$(m_Find)

  Set Folders = Application.Session.Folders
  LoopFolders Folders

  If Not m_Folder Is Nothing Then
      Set Application.ActiveExplorer.currentFolder = m_Folder
  End If
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders)
  Dim F As Outlook.MAPIFolder
  Dim Found As Boolean
  
  If SpeedUp = False Then DoEvents

  For Each F In Folders
      Found = (LCase$(F.Name) = m_Find)

    If Found Then
      Set m_Folder = F
      Exit For
    Else
      LoopFolders F.Folders
      If Not m_Folder Is Nothing Then Exit For
    End If
  Next
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Two tweaks in this code - first moves the message to a folder named the senders display name (it's commented out in the code).

Second option is putting the senders address in the folder description and moving the message based on that. Adding the email address to the description field would be a pita (right-click on folder > Properties then add the address to the description field)... but the folder name could be anything - and if it's used for multiple senders, you can use instr function to look for the address in the description string.


Code:
Private m_Folder As Outlook.MAPIFolder
Private m_Find As String

Private Const SpeedUp As Boolean = True

Public Sub FindFolder()
  Dim objApp As Outlook.Application
  Dim objItem As MailItem
  Dim Name$
  Dim Folders As Outlook.Folders
    
  Set objApp = Application

  Set m_Folder = Nothing
  m_Find = ""

  Set objItem = objApp.ActiveExplorer.Selection.Item(1)
'  Name = objItem.SenderName
  Name = objItem.SenderEmailAddress
  Debug.Print Name
  If Len(Trim$(Name)) = 0 Then Exit Sub
  m_Find = Name

  m_Find = LCase$(m_Find)

  Set Folders = Application.Session.Folders
  LoopFolders Folders

  If Not m_Folder Is Nothing Then
    '  Set Application.ActiveExplorer.currentFolder = m_Folder
      objItem.Move m_Folder
  End If
End Sub

Private Sub LoopFolders(Folders As Outlook.Folders)
  Dim F As Outlook.MAPIFolder
  Dim Found As Boolean
 
  If SpeedUp = False Then DoEvents

  For Each F In Folders
     ' Found = (LCase$(F.Name) = m_Find)
      Found = (LCase$(F.Description) = m_Find)

    If Found Then
      Set m_Folder = F
      Exit For
    Else
      LoopFolders F.Folders
      If Not m_Folder Is Nothing Then Exit For
    End If
  Next
End Sub
 

Fred Dagg

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Thanks Diane. What you seem to be driving at there is an automated way to jump to a folder based on the sender, which I can see makes sense given the example I used of filing incoming email.
The thing is its not just an automated filing I'm look for. That was just one use for being able to jump to a specific folder.

Take another example. Suppose for each customer subfolder in Customers folder, I create subfolders "To Do" & "Ignore". Now I want to go to Customers\Fred\Ignore. With that Find code, I'd find many results if I typed Ignore. I could type Fred but thats fine for Fred, not for The Very Little Bottling Co. I guess another answer is NOT to have Customers in favorites, then use the find code for Customers. But I have to type out C u s t o m..... instead of simply clicking a button/link/etc.
I'll play with it some more and maybe use a combination of all. Many thanks.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I know it's not what you were looking for... but tweaking macros is fun. :)

The best macro is whichever one is the fastest.

then use the find code for Customers. But I have to type out C u s t o m..... instead of simply clicking a button/link/etc.
If you are always opening Customers... you'd want to just activate it. That's fastest. If you aren't filing anything in Customers folder, only in the subs, it doesn't need to use on favorites. But if it is, pick an existing subfolder to activate.

Code:
Sub openFolder()

 Dim objOlApp As Outlook.Application
 Dim objFolder As Outlook.Folder
 Set objOlApp = CreateObject("Outlook.Application")

' subfolder of inbox
'Set objFolder = Session.GetDefaultFolder(olFolderInbox).Folders("Customers")

'same level as inbox
Set objFolder = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Customers")

 Set objOlApp.ActiveExplorer.CurrentFolder = objFolder

 Set objFolder = Nothing
 Set objOlApp = Nothing

End Sub
 
Similar threads
Thread starter Title Forum Replies Date
F Jump to Inbox folder when click on Favorite Using Outlook 0
T Outlook 2013: How did "Inbox" emails jump straight to the "Recover Deleted Items" Folder? Using Outlook 2
R Search/Jump to a folder by typing its name Outlook VBA and Custom Forms 1
Victor_50 jump to actual folder from favorite Outlook VBA and Custom Forms 1
I jump to body in open message with one keyboard shortcut? Using Outlook 3
A In Contacts Phone List View, allow alpha jump w/single key, same as Card views Using Outlook 4
R Moved 6 months worth (approx 1500 emails) lost from moving from TPG inbox to Icloud inbox (folders) Using Outlook 3
S Problem Checking the available stores in my Inbox (Outlook VBA) Outlook VBA and Custom Forms 0
S Outlook VBA How to adapt this code for using in a different Mail Inbox Outlook VBA and Custom Forms 0
A Inbox didn't got read Outlook VBA and Custom Forms 0
A Unflag Inbox and Flag Inbox with Orange Category After Item is send Outlook VBA and Custom Forms 3
glnz O365 - How to combine the Inboxes for four email accounts into a single Inbox Using Outlook 7
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
G Inbox shows old email Using Outlook 3
C Configuring Inbox columns Using Outlook 2
D Inbox column color coding Using Outlook 2
R Outlook 2010 How do you export 2 email Accounts' 2010 Inbox Files to new computer (2019)? Using Outlook 0
J Collaborative Inbox Using Outlook 1
M Missing emails in Inbox, but are present in webmail Using Outlook 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
P Outlook Mobile App Doesn't Refresh Inbox Using Outlook 0
H In outlook 365 POP mail Inbox, email takes a long time or never arrives. Using Outlook 1
K No emails in inbox Using Outlook.com accounts in Outlook 1
D Unopened message in inbox deleted and not in deleted items Using Outlook 3
R Exporting recovered Deleted Items outside the Inbox Using Outlook 1
N Focussed Inbox Rules Failing Using Outlook 5
M Inbox not showing to deliver new email to this account Using Outlook 3
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
T Inbox Sub-Folder - Web Using Outlook 1
P Two main Outlook gripes: Voting buttons not working externally nor Focused Inbox Using Outlook 1
P when i move inbox mails to another folder in outlook the mail disappears Using Outlook 1
B VBA Macro for assigning multiple Categories to an email in my Inbox Outlook VBA and Custom Forms 1
N Syncing my inbox not working for certain types of mail Using Outlook 9
D How to handle filing of emails from an Inbox Subfolder to a specific Public folder Using Outlook 1
E Outlook 2016 Inbox search bug Using Outlook 1
O Having rules run on old mails noved to inbox Outlook VBA and Custom Forms 8
K Outlook 2010 duplicate download emails 1 inbox 1 PST no updates Using Outlook 3
LolaArrabal My huge inbox folder Using Outlook 2
M VBA macro for Inbox's attachments search Outlook VBA and Custom Forms 0
M Emails being sent to Inbox and IPM_Subtree Using Outlook.com accounts in Outlook 4
E Don't want Inbox shown when login box is shown Using Outlook 1
B Copy/Move Exchange inbox to Pop inbox Using Outlook 4
S Send email via SMTP - use transport rules to add to senders inbox (then rule to move to sent items Exchange Server Administration 1
S Accepting meeting request from calendar keeps the meeting request in the inbox Using Outlook 2
S VBA Code to move mail items from search folder to inbox subfolder Outlook VBA and Custom Forms 4
F want inbox on toolbar to reference icloud messages Using Outlook 2
E Inbox field customization Using Outlook 1
M Ensure the same inbox view across multiple outlook instances Using Outlook.com accounts in Outlook 7

Similar threads

Top