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

Status
Not open for further replies.

reubendayal

Senior Member
Outlook version
Outlook 365 64 bit
Email Account
Office 365 Exchange
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
 
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
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Witzker print-list-of-outlook-folders with sort posibility Outlook VBA and Custom Forms 7
Diane Poremsky Print a list of your Outlook folders Using Outlook 0
D Create folders for to-do list? Using Outlook 1
2 All task folders not in To-D0 list.... Using Outlook 1
R how do I print a list of folders/subfolders in Inbox Outlook VBA and Custom Forms 1
Rupert Dragwater Contact list didn't download Using Outlook 1
S Default Selection For Multi-Select List Box Outlook VBA and Custom Forms 1
D DB/Object/Record vs File/List/Range Terminology Outlook VBA and Custom Forms 0
farrissf Category list to pick from Outlook VBA and Custom Forms 4
R Outlook 2019 VBA to List Meetings in Rooms Outlook VBA and Custom Forms 0
S Inconsistent view of To-Do List Using Outlook 0
S Different views for To-Do List and To-Do Bar Using Outlook 0
R Adding Userform Dropdown List items from names of subfolders on network drive Outlook VBA and Custom Forms 10
K Daily Task List Minimized Cannot Display Using Outlook 5
S Outlook 2021 Can you make emails from 3 word domains "safe" by entering top 2 word domain into Safe List in Outlook? Using Outlook 1
E Outlook - Macro - send list of Tasks which are not finished Outlook VBA and Custom Forms 3
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
D VBA code to select a signature from the signatures list Outlook VBA and Custom Forms 3
L Checking Sender Email Address for trusted domain from list on intranet Outlook VBA and Custom Forms 4
NVDon Create new Move To Folder list Outlook VBA and Custom Forms 0
Ken Pascoe Outlook Categories Quick List Using Outlook 0
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
N How do I make Outlook autocomplete addresses from a list of recognised <full_names> only? Using Outlook 2
T Outlook 2010 Tasks are not visible in To Do list Using Outlook 5
C must select message to trigger safe list Using Outlook 3
N contact list seen in Contact folder but knot in Address book or when 'TO' button is clicked in new email Using Outlook 0
V Pin a document to the "Attach file" Recent Documents list Using Outlook 0
T Junk Email does not get added to the Blocked Sender List Using Outlook 0
F Junk Email does not get added to the Blocked Sender List Using Outlook 4
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
Z See "Change View" Drop Down as a List? Using Outlook 1
Z 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 28
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

Similar threads

Back
Top