I'm looking for some help, I would like to create some code that I can take all the emails in my INBOX and move them to the INBOX of my personal folder.
Here's some code that I have been using. Replace "Short Term Archive" with the name of the .pst file that you want to store messages in. Enjoy.
Sub ClearInbox()
On Local Error Resume Next
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myinbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myinbox.Items
Set myDestFolder = Application.GetNamespace("MAPI").Folders("Short Term Archive").Folders("Inbox")
Set myItem = myItems.Find("[SenderName] <> 'Joe Blow'")
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.