I've been trying to figure out a similar issue and I'm so so thankful to the OP for getting this topic started. Thank you!
But, I'm dumb, and I have questions.
I tried this code, and I'm not sure exactly what I'm doing wrong here.
I noticed the code below this obviously wouldn't work on my machine as I have different folders.
I changed that section of the code to match my folders.Set olFolder = Application.Session.PickFolder Set olDestFolder = Application.Session.GetDefaultFolder(olFolderInbox).folders("Test").folders("Test A"
emailbox.jpg
So I thought the code should look like this:
However, that gave me an object not found exception.Sub MoveMessages()Dim olFolder As Folder Dim olDestFolder As Folder Dim olItems As Outlook.Items Dim strFind As String Dim i As Long, j As Long: j = 0 strFind = InputBox("Find what text?") If strFind = "" Then GoTo lbl_Exit Set olFolder = Application.Session.PickFolder Set olDestFolder = Application.Session.GetDefaultFolder(olFolderInbox).Folders("Inbox").Folders("Test") Set olItems = olFolder.Items For i = olItems.Count To 1 Step -1 If TypeName(olItems(i)) = "MailItem" Then If InStr(1, olItems(i).Subject, strFind) > 0 Then olItems(i).Move olDestFolder j = j + 1 End If End If Next i MsgBox j & " message items moved" lbl_Exit: Set olItems = Nothing Set olFolder = Nothing Set olDestFolder = Nothing Exit Sub End Sub
So what am I doing wrong here, I'm very new to Outlook VBA and a novice (though I have put together a few of my own programs for Excel and Word) in general with VBA.![]()
I even tried just using this:
That allowed me to actually bring up the search box but when I searched for "Emma" nothing moved.Set olDestFolder = Application.Session.GetDefaultFolder(olFolderInbox)
Assuming I can get this figured out, is there a way to search message bodies for a series of string values?
Thanks!
![]()




Reply With Quote
