+ Reply to Thread
Results 1 to 5 of 5

Thread: Move Inbox Subfolder Items by Category to Folder

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    184

    Move Inbox Subfolder Items by Category to Folder

    Hi,
    I would like to move items from the inbox to a different folder based on category. Because the category will be manually changed (to "done"), it won't be able to happen on send/receive.
    I'm familiar with VBA in Excel but not in Outlook.

    Any suggestions for how I might accomplish this? (Move from Florida inbox to Done inbox)

    Thank you.
    Karin
    (Outlook 2010)
    Last edited by ker9; 08-30-2011 at 02:03 PM.

  2. #2
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    184

    Re: Move Inbox Items by Category to Folder

    I've got this code, but it breaks on the line indicated

    Sub MoveItems()
    
             Dim myOlApp As New Outlook.Application
    
             Dim myNameSpace As Outlook.NameSpace
             Set myNameSpace = myOlApp.GetNamespace("MAPI")
     
             Dim myBox As Outlook.MAPIFolder
             Set myBox = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("!PS-In-Florida")
    
             Dim myDestFolder As Outlook.MAPIFolder
             Set myDestFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("PS-Completed Items")
    
             Dim myItems As Outlook.Items
             Set myItems = myBox.Items
             
             Dim myItem As Object
    'BREAKS ON NEXT LINE - not supported
             Set myItem = myItems.Categories = "@Done-Karin"
    
             While TypeName(myItem) <> "Nothing"
    
                     myItem.Move myDestFolder
    
                     Set myItem = myItems.FindNext
    
             Wend
    
    End Sub
    Last edited by ker9; 08-29-2011 at 02:29 PM.

  3. #3
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    184

    Re: Move Inbox Items by Category to Folder

    I've got this to work (am VERY excited!) - want to be able to find multiple categories, that is the next part of the puzzle.

    Sub MoveDoneItems()
    
             Dim myOlApp As New Outlook.Application
    
             Dim myNameSpace As Outlook.NameSpace
             Set myNameSpace = myOlApp.GetNamespace("MAPI")
     
             'box to look at
             Dim myBox As Outlook.MAPIFolder
             Set myBox = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("!PS-In-Florida")
    
             'box to move to
             Dim myDestFolder As Outlook.MAPIFolder
             Set myDestFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("PS-Completed Items")
    
              Dim myItems As Outlook.Items
             Set myItems = myBox.Items
             
             Dim myItem As Object
             Set myItem = myItems.Find("[Categories] = @Done-Karin")
             
             While TypeName(myItem) <> "Nothing"
                     myItem.Move myDestFolder
                     Set myItem = myItems.FindNext
             Wend
    
    End Sub

  4. #4
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    184

    Re: Move Inbox Subfolder Items by Category to Folder

    Well, I've spent the whole day on this, and while I did make great progress, it would seem that you cannot search a wildcard character on categories. So I'm thinking maybe do something like copy (through vba) the existing categories to some other field that I can search on. If anyone has ideas, I'd love some help.
    Thanks!

  5. #5
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Tampa, FL
    MS-Off Ver
    Excel 2007
    Posts
    184

    Re: Move Inbox Subfolder Items by Category to Folder

    With many, many thanks to:
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007

    Who responded to my plea for help in a different forum, below is the final result.

    Sub MoveDoneItems2()
    
            Dim myOlApp As Outlook.Application
                Set myOlApp = Application
    
            Dim myNameSpace As Outlook.NameSpace
                Set myNameSpace = myOlApp.GetNamespace("MAPI")
     
            'box to look at
            Dim myBox As Outlook.MAPIFolder
                Set myBox = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("@test")
    
            'box to move to
            Dim myDestFolder As Outlook.MAPIFolder
                Set myDestFolder = myNameSpace.GetDefaultFolder(olFolderInbox).Folders("PS-Completed Items")
    
            Dim myItems As Outlook.Items
                Set myItems = myBox.Items
             
            Dim sFilter As String
                sFilter = "@SQL=" & Chr(34) & "urn:schemas-microsoft-com:office:office#Keywords" & Chr(34) & " LIKE '@Done%' "
             
            Dim myItem As Object
                Set myItem = myItems.Find(sFilter)
             
            While TypeName(myItem) <> "Nothing"
                myItem.Move myDestFolder
                    Set myItem = myItems.FindNext
            Wend
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0