Consulting

Results 1 to 2 of 2

Thread: Move Mail to folder based on Category

  1. #1
    VBAX Newbie
    Joined
    Jan 2017
    Posts
    1
    Location

    Move Mail to folder based on Category

    Hello,

    My job requires me to keep track of my incoming e-mails. I have rules set up that if it has specific wording it gets categorized red as "Bid due" and it gets put in a folder named "Bids" . After I do what I need to do with the email I change the category to blue as "Done". I want to then have that e-mail moved to my "Done" folder. Can someone help me come up with a script to do this? Also is there a way to remove the red category automatically after I change it to blue?

    Thanks,

    VBA Noob

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Option Explicit
    
    Private Sub SetCategoryDone_MoveToFolderDone()
    
    Dim itm As mailItem
    
    ' Select the item
    Set itm = ActiveExplorer.Selection(1)
    
    ' Replace existing category with Done
    itm.Categories = "Done"
    
    ' Move to a folder directly under the default inbox
    itm.Move Session.GetDefaultFolder(olFolderInbox).Folders("Done")
    
    ' Move to a folder buried deeper
    ' Add as many  ".Folders("name of subfolder")  as needed
    ' itm.Move Session.GetDefaultFolder(olFolderInbox).Folders("name of subfolder").Folders("Done")
    
    End Sub
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •