Consulting

Results 1 to 4 of 4

Thread: Category to Folder

  1. #1
    VBAX Newbie
    Joined
    Apr 2018
    Posts
    2
    Location

    Category to Folder

    Hi, I work with huge amounts of emails. To make it easier I have created multiple rules to first assign category to the email based on their senders address (this is on receiving them) and then manually move all categories at once to specific folders. I was thinking that maybe I can do this by macro but I have no idea on how outlook macro work. I'm only used to excel macros.

  2. #2
    Why don't you simply use the rule to move the message to the required folder as it arrives?
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    Apr 2018
    Posts
    2
    Location
    Because I would like to keep all mails in the inbox to make sure not to miss anything. and then once I go through them, move to another folder
    So my idea is to create a macro that categorizes the email once received automatically and then triggering another macro to move anything that has a category to a specific folder

  4. #4
    The easiest solution is to use the Outlook Today screen and add your folders to the list displayed. Then you shouldn't miss any as the list will display unread messages. However the following should work, provided the named folders are direct sub folders of the default inbox and the named folders exist. Change the category names and folder names as appropriate.

    Sub MoveCategory()
    Dim olItems As Outlook.Items
    Dim olItem As Outlook.MailItem
    Dim i As Long
    Dim strFolder As String
        Set olItems = Session.GetDefaultFolder(olFolderInbox).Items
        olItems.Sort "[Received]", True
        For i = olItems.Count To 1 Step -1
            Set olItem = olItems(i)
            Select Case olItem.Categories
                Case "Category Name 1"
                    strFolder = "Foldername for Category Name 1"
                Case "Category Name 2"
                    strFolder = "Foldername for Category Name 2"
                Case "Category Name 3"
                    strFolder = "Foldername for Category Name 3"
                    'etc
                Case Else
                    strFolder = ""
            End Select
            If Not strFolder = "" Then
                olItem.Move Session.GetDefaultFolder(olFolderInbox).folders(strFolder)
            End If
        Next i
    CleanUp:
        Set olItems = Nothing
        Set olItem = Nothing
    lbl_Exit:
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

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