Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oultook VBA

Status
Not open for further replies.

rss01

Technical User
Oct 10, 2001
125
US
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.

Any help would be appreciated.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top