List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email

reubendayal

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server 2013
Hi All,

I work with several cases that are subfolders under 2 different shared mailboxes. When replying to an email on a specific case, I need to move it to the case folder, and then reply to it (so the reply gets saved in the same folder). So I am trying to find a faster way of doing this.

The problem is the step with putting together a macro that can list all the sub folders from the two shared mailboxes. What I need help with is (to describe in a chronological manner):
  1. once I have selected an email/s in the inbox, i call the macro by a keyboard shortcut,
  2. the macro then displays a list of folders from the two shared mailboxes, and i just need to type the case folder name's first or second characters for the combobox to select it, and then hit okay,
  3. the macro then selects the path of the case folder, and moves the email/s I had selected to the subfolder's path
  4. it then selects the sub folder as the active folder and ReplyAll to the email that was just moved (else replyall to the latest of the emails that were moved)
My below macro is only able to move a selection of the emails to a folder, but uses the pickfolder method that is super slow. And eventually when the email/s are moved, and I select the subfolder as the active folder, outlook simply selects the latest message or the last selected message in that folder - which means I lose track of the email that was moved. So doesnt achieve what I am trying to do.

Code:
Sub InitiationMoveEmail_GotoFolder()

    Dim objNS As Outlook.NameSpace
    Dim objDestFolder As Outlook.MAPIFolder
    Dim objItem As Outlook.MailItem
        
    Set objNS = Application.GetNamespace("MAPI")
    
' Pick the destination folders
   Set objDestFolder = objNS.PickFolder

  If Not (objDestFolder Is Nothing) Then
    Set objItem = Application.ActiveExplorer.Selection.Item(1)
        For Each objItem In ActiveExplorer.Selection
            objItem.Move objDestFolder
        Next
    Set Application.ActiveExplorer.CurrentFolder = objDestFolder
    
    Else
        MsgBox "Outlook Folder is not created!", vbOKOnly + vbCritical, "Exiting Automation"
    Exit Sub
        
  End If
 
  Set objDestFolder = Nothing
  Set objNS = Nothing


End Sub
 

reubendayal

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Exchange Server 2013
Hi All,

Anyone that can help with the above issue?

Additionally, I have tried tweaking Diane's helpful code on printing the outlook folder list. But the macro does take quite a while (approx. 10-15 seconds) to retrieve the folder list and then it only displays the list in an email, and I am unsure on how to make it display the same in a combobox macro instead.

Code:
Public Sub GetFolderNames()
    Dim olApp As Outlook.Application
    Dim olSession As Outlook.NameSpace
    Dim olStartFolder As Outlook.MAPIFolder
    Dim MyFolder As Folder

    Set olApp = New Outlook.Application
    Set olSession = olApp.GetNamespace("MAPI")
      
     ' Allow the user to pick the folder in which to start the search.
    
    Set MyFolder = Session.Folders("DK Mailbox").Folders("Inbox").Parent.Folders("Assignees 2020")
    
    Set olStartFolder = MyFolder 'olSession.PickFolder
      
     ' Check to make sure user didn't cancel PickFolder dialog.
'    If Not (olStartFolder Is Nothing) Then
         ' Start the search process.
        ProcessFolder olStartFolder
'    End If
    
'*** Create a new mail message with the folder list inserted
Set ListFolders = Application.CreateItem(olMailItem)
  ListFolders.Body = strFolders
  ListFolders.Display
      
'MsgBox strFolders
      
' clear the string so you can run it on another folder
  strFolders = ""
End Sub
 
Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder)
        
    Dim i As Long
    Dim olNewFolder As Outlook.MAPIFolder
    Dim olTempFolder As Outlook.MAPIFolder
    Dim olTempFolderPath As String
     ' Loop through the items in the current folder.
    For i = CurrentFolder.Folders.Count To 1 Step -1
          
        Set olTempFolder = CurrentFolder.Folders(i)
          
        olTempFolderPath = olTempFolder.FolderPath

'     ' Get the count of items in the folder
'         olCount = olTempFolder.Items.Count
'
'     'prints the folder path and name in the VB Editor's Immediate window
         'Debug.Print olTempFolderPath '& " " & olCount
          
        ' prints the folder name only
          'Debug.Print olTempFolder
          
         ' create a string with the folder names.
         ' use olTempFolder if you want foldernames only
         strFolders = strFolders & vbCrLf & olTempFolder ' & " " & olCount
        
        'lCountOfFound = lCountOfFound + 1
          
    Next
     ' Loop through and search each subfolder of the current folder.
    For Each olNewFolder In CurrentFolder.Folders
          
         'Don't need to process the Deleted Items folder
        If olNewFolder.Name <> "Deleted Items" Then
            ProcessFolder olNewFolder
        End If
          
    Next
    
End Sub
 
Thread starter Similar threads Forum Replies Date
Diane Poremsky Print a list of your Outlook folders New Slipstick.com Articles 0
D Create folders for to-do list? Using Outlook 1
2 All task folders not in To-D0 list.... Using Outlook 1
R Change Public Folders Label in Folder List Using Outlook 1
S OUTLOOK mail folders. Order of list. Using Outlook 2
N Favorite Folders list in outlook navigation pane, can you add a message to the favorite folder list Using Outlook 2
O How to put the most used folders in the Favorites Folders list? Using Outlook 2
R how do I print a list of folders/subfolders in Inbox Outlook VBA and Custom Forms 1
G Move tasks up/down todo list by VBA Outlook VBA and Custom Forms 1
E Asking user to select multiple options in a list in an email Outlook VBA and Custom Forms 0
C Why won't Title display in message list? Using Outlook 1
T Increasing the number of items that appear on the Categories list Using Outlook 2
J Edit auto-complete list in Outlook 2016+/365? Using Outlook 0
M Changing the preferred order for "Put this entry in" list for adding new contacts to the Address Book Using Outlook 1
B See "Change View" Drop Down as a List? Using Outlook 1
B How to show concatenated categories in list task view? Using Outlook 2
M How can we find the list of users who are members of a deleted distribution list? Exchange Server Administration 2
B Outlook 365 - Folder pane list clears Using Outlook 24
B All imported tasks appear in to-do list Using Outlook 3
W Remove specific contacts from contact list Outlook VBA and Custom Forms 3
GregS 2016 Contact List being managed by Outlook.com? Using Outlook 1
B Outlook - Mail from safe senders list being sent to Spam Folder Using Outlook 0
M Message list font changed after update Using Outlook 2
A Order of Recent Items in Attach File List Using Outlook 5
O Address list - company and non-company ? Using Outlook 0
E To convert imported data to custom fields in Task list Outlook VBA and Custom Forms 1
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
I Help with dates in task list. Using Outlook 5
M Daily Task List Minimized Cannot Display Using Outlook 2
M Same file "stuck" on top of file list in "Attach File" drop down Using Outlook 4
M Auto expand Distribution List Before Sending Email Outlook VBA and Custom Forms 1
A Move email items based on a list of email addresses Outlook VBA and Custom Forms 40
N Outlook 2010 Flag blocked for Safe Senders List???? Using Outlook 7
Jennifer Murphy To Do List Views Using Outlook 0
A Add multiple servers "on behalf of" email to "safe senders" list. Using Outlook 1
P Message List Font Changed Using Outlook 6
Z Adding dropdown list using custom form Outlook VBA and Custom Forms 7
M tasks in todo list appearing twice Using Outlook 3
G Entered data in custom field goes in card and does not stay in list view Outlook VBA and Custom Forms 1
W Deleting Sent Task Email, Deletes the task from my list Using Outlook 1
G Unable to dismiss reminders from share point list calendar shared in Outlook Using Outlook 2
F Sharepoint tasks from multiple accounts in To-Do List Using Outlook 8
Rupert Dragwater How to import contact list Using Outlook 15
M I'm Having problems Moving Contacts to a New List Using Outlook 8
D Overlapping Names in Folder List Using Outlook 4
JohnViuf Export task list view settings to other pc Outlook VBA and Custom Forms 16
I Flagged emails in pst file corrupt to do list Using Outlook 12
S Outlook.com birthdays show up 1 day late on iPhone contacts list Using Outlook.com accounts in Outlook 28
T One Contact list, two sections of company (none) Using Outlook 2
M Outlook.com autocomplete list invaded by strange items Using Outlook.com accounts in Outlook 7
Similar threads


















































Top