Closed CGDaveMac closed 5 years ago
Same here! Glad you find this functionality useful.
The "No folders found" error occurs when none of the emails in the conversation are in a folder other than Inbox or Sent Items. To see the other emails in the conversation, enable conversation view by clicking the View tab in the Outlook Ribbon and then checking the box for "Show as Conversations."
Then, move the first email in the conversation to a specific folder. Next, run the macro on the latest email in the conversation. A notification should appear saying it moved the second email to the same folder as the first.
Thanks for the quick response! I will have to try again tomorrow at work, but I do have conversation view on. Is there a limit to how "deep" the folders are? Most of mine are nested 3-4 (or more) layers deep.
There should be no limit to how deep your folders are since it treats the folder path as a single string rather than nested folders.
I did notice that it didn't work if the email chain contained a meeting. The commit I just pushed (204ec6c820d99513221a5b8a7ef274cf801dead0) fixes the issue for me. If this doesn't fix it or the issue is something else, can you try a minimal example such as the following?
The macro should move the second message to the same folder as the first message and provide a message box stating it moved.
I will try tomorrow.
On the emails I tried, I don't think any had meetings. Also, I don't think this should affect anything, but my security settings required that macros be signed, so I signed the macro with my own credentials.
Found the problem, but I can't exactly work out why. (I did not have enough time to really debug today.)
In GetConversationInforation, there is a problem with the following code:
If (InStr(fld.FolderPath, "Inbox") = 0) And (InStr(fld.FolderPath, "Sent Items") = 0) And (IsInListBox = False) Then Me.ListBox1.AddItem fld.FolderPath End If
As written, this code is executed the first time, and never matches the three conditions and skips down to "No Folders Found." I removed the If statement and everything works. I imagine the unintentional consequence is that it will try to move emails to the Inbox if that's the only place they are.
I had some additional time, and found the problem... my FolderPath ALWAYS contains “Inbox” because all of my folders are sub folders of the inbox. I solved this by moving them into an Archive folder. I wonder if this is the best practice and should be added to the README, or the code for searching could be tweaked to ensure the string doesn’t end with the word Inbox.
Good catch! I have a fix I will push today. The issue is that in order to avoid populating the ListBox with Inbox, Sent Items, and Calendar on every thread, the macro ignored all folders with those names anywhere in the path.
The fix I have will ignore those folders but not any of their subfolders.
Thanks buddies, I'm looking forward the update to test it! Not sure how to update a self created macro though...
Please verify commit 81a42e4affaad100876fef6093952f1ff195a7af fixes the issue. To update the macro, download the changed files (ListThreadFolders.frm
and ListThreadFolders.frx
) and import them.
If it does not fix the issue, could you copy and paste the details from the Immediate Window? It can be accessed within the VBA editor under the View menu or with the shortcut Ctrl+G. Thanks for the feedback!
Hello @KyleWJohnston
I updated the macro and when I run it I have a new error :
Run time error 438
Object doesn't support this property or method
When I click on the "debug" button it highligths :
==> ListThreadFolders.Show
I appreciate the feedback. Can you check what VBA references are enabled? Here's how:
Also, are there any messages in the Immediate Window after running the macro? Open the Immediate Window with Ctrl+G from the VBA editor and copy any messages here.
The following seem activated on my end :
Visual Basic For Applications
Microsoft Outlook 16.0 Object Library
Microsoft Office 16.0 Object Library
OLE Automation
Microsoft Forms 2.0 Object Library
Oh and nothing in the immediate window, Only the error code I list above (code 438 and the line ListThreadFolders.Show is highlighted in yellow when I click on debug.
Just realized I actually am using Outlook 2016, not 2010.
I got the same error, but stepped into the debugger. Some of the Debug lines produce errors, but not all. Here are the ones that do, plus a screenshot of the error:
Debug.Print ("Selected item: " & selectedItem)
'Debug.Print ("Moved '" & objItem & "' to '" & objDestFolder & "'")
'Debug.Print ("Skipped moving '" & objItem & "' to '" & objDestFolder & "' (same folder)")
I commented the out and the macro works perfectly, including items that are in Inbox sub folders.
I commented the 3 debug lines and it works. It feels so good. Do you think we could put a timer for the popup to disappear by itself after 2 second for example ? Or better, when we click on the macro a drop down list appear showing the detected folders and we simply select where to send ? No popup window then, even better.
Great find! I'm not sure what the deal with those debug lines is. I'm running Outlook 2016 as well and they all work fine on my machine. I'll comment out those lines to close this issue, but I'd like to know why they're not working.
To remove the confirmation window after an email is automatically moved (only 1 folder in the thread), comment out the following line near the bottom of GetConversationInformation
:
MsgBox ("Moved email(s) to " & Me.ListBox1.Column(0, 0))
We can look for alternatives to the MsgBox and ListBox, but it should be a separate issue. Pressing enter will accept the MsgBox "Moved email(s) to..." confirmation.
I might have found the issue, but I don't know why it works on my computer. Do the following debug lines work? I specified properties that return strings.
Debug.Print ("Selected item: " & selectedItem.ConversationTopic)
Debug.Print ("Moved '" & objItem.ConversationTopic & "' to '" & objDestFolder.name & "'")
Debug.Print ("Skipped moving '" & objItem.ConversationTopic & "' to '" & objDestFolder.name & "' (same folder)")
Those work just fine.
So should this bug be closed and the rest lived into feature request?
I'll close this with a commit tonight. The rest can be a feature request.
Forgot to push to GitHub. Closed with commit 1f3e1c205514a90ce495b4411c236a1bacdc2acf.
I have been trying to get this working in Outlook 2010 and I imported the two files individually and the macro runs fine, no errors, just a pop up that no folders were found. I have been longing for this capability for a long time! Any ideas?