Results 1 to 13 of 13

Thread: Categorizing emails based on the subject

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    VBAX Regular
    Joined
    Mar 2019
    Posts
    7
    Location
    I copy pasted it at the top of the ThisOutlookSession.
    the error message is gone now, but it still doesn't run automatically...

    Regarding the attachement, this portion of code can be part of my main code?
    Like:

    Public Sub autocategories()
    Dim olItem As Object
        For Each olItem In Application.ActiveExplorer.Selection
            If InStr(1, olItem.Subject, "[cat1]", vbTextCompare) > 0 Then
                olItem.Categories = "CAT1"
            ElseIf InStr(1, olItem.Subject, "[cat2]", vbTextCompare) > 0 Then
               olItem.Categories = "CAT2"
               For i = 1 To olItem.Attachments.Count
                   If InStr(1, olItem.Attachments(i).fileName, "[CAT1]", vbTextCompare) > 0 Then
                       olItem.Categories = "CAT1"
                       olItem.Save
                       Exit For
                   End If
              Next i
             olItem.Save
        Next olItem
        Set olItem = Nothing
    End Sub
    Or should it be part of a different macro?
    Last edited by Aussiebear; 01-18-2025 at 02:44 PM.

Posting Permissions

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