Guys, I have cobbled together the below code to move emails from one folder to another. I attached my code and original message it won't let me paste here.
Thank you,
Guys, I have cobbled together the below code to move emails from one folder to another. I attached my code and original message it won't let me paste here.
Thank you,
Assuming that you are running this macro fro Outlook, you don't need to create a new Outlook instance. Use the active one.
You haven't told the macro what objItem is.
Assuming your paths are correct the following should work and I see nothing wrong with the line in question
Sub MoveDraftMail() Dim objNamespace As Outlook.NameSpace Dim objSourceFolder As Outlook.MAPIFolder Dim objDestFolder As Outlook.MAPIFolder Dim objItem As Object Dim Archive_Folder As Outlook.MAPIFolder Set objNamespace = Application.GetNamespace("MAPI") Set objSourceFolder = objNamespace.folders(10).folders("HouseBillofLadingReport") Set Archive_Folder = objNamespace.folders("Online Archive - My@email").folders("Personal_Folders").folders("2021").folders("InBox") For Each objItem In objSourceFolder.items If TypeName(objItem) = "MailItem" Then objItem.Move Archive_Folder End If DoEvents Next objItem Set objDestFolder = Nothing Set objNamespace = Bothing Set objSourceFolder = Nothing Set Archive_Folder = Nothing Set objItem = Nothing End Sub
Graham Mayor - MS MVP (Word) 2002-2019
Visit my web site for more programming tips and ready made processes
http://www.gmayor.com
Gmayor....you nailed it. Thank you!