Solved

Outlook Macro - Move read Messages

Posted on 2010-09-22
9
552 Views
Last Modified: 2013-12-20
I need a Marco that will be able to move all read messages from my indox to another folder called read messages when I hit a certant key combination on the keyboard.   I have Outlook 2007,  I have read over many articles and blog posts on doing something similar to this but can never get it to work.  I am not that great with VBA Code to make sense of what is going on in the code I have come across to determin if it is what i need or not.  Most of the code I have come across does extra things that I do not need or is just a bit different than just a simple moving of read mail to a specific folder.

0
Comment
Question by:nck534
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 33742108
Hi, nck534.

Moving the messages is simple.  The code below should take care of that.  The key combination part is more of a problem.  The only way to run a macro via a key combination is to add a toolbar button or menu item that runs it and assign a hot key to it.  The hot keys that Outlook allows are limited and if the macro is available via a button, then I'm not sure I see the value in a hot key.
Sub MoveReadItems()
    Dim intIndex As Integer, olkItem As Object, olkInbox As Object, olkFolder As Object
    Set olkInbox = Session.GetDefaultFolder(olFolderInbox)
    'Assumes that the folder Read Messages is at the same level as the Inbox'
    Set olkFolder = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("Read Messages")
    For intIndex = olkInbox.Items.count To 1 Step -1
        Set olkItem = olkInbox.Items(intIndex)
        If olkItem.UnRead = False Then
            olkItem.Move olkFolder
        End If
    Next
    Set olkItem = Nothing
    Set olkFolder = Nothing
End Sub

Open in new window

0
 
LVL 1

Author Comment

by:nck534
ID: 33769563
Thank you for helping me out with this,  Where in this code will I put the name of the destination folder for read messages?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33771175
Line #5.  As I mentioned in the comment I included in the code, the code assumes that the "Read Messages" folder is at the same level as the Inbox.  If the folder is at a different level, then the code on line #5 will have to be changed.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 1

Author Comment

by:nck534
ID: 33771999
Works, Thank you for all of your help
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33772194
You're welcome.  Glad I could help.
0
 
LVL 1

Author Comment

by:nck534
ID: 33809749
What would the code be on line #5 if the Read Messages folder was inside of the Inbox?
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33809785
If "Read Messages" is a folder under the inbox, the line #5 would look like this

Set olkFolder = Session.GetDefaultFolder(olFolderInbox).Folders("Read Messages")
0
 
LVL 1

Author Comment

by:nck534
ID: 33844304
Thanks it worked.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33844399
You're welcome.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question