morfizm (morfizm) wrote,
morfizm
morfizm

Outlook Rules

For Outlook users who use nested folders.

If you're using Outlook with Exchange, and a new mail comes into nested folder, the parent folder doesn't get expanded. It's cool, because you can channel your low-priority mails into a subfolder without making them distract you.

If you're using Outlook with PST and moving e-mails with rules, parent folder will be expanded every time a new e-mail comes in. You would also run into this problem if you're using Exchange, but want to add client-only functionality to your rules (such as "mark as read").

What I tried to do is to use Outlook VBA macros and "run a script" rule. I didn't succeed much: they work intermittently and stop working at random point in time. I asked Outlook experts for advice and they told me that running a script isn't a recommended way. I should implement the whole thing using VBA, per article:

"How to create a custom rule using Visual Basic for Applications (VBA) in Outlook 2002"
http://support.microsoft.com/default.aspx?scid=kb;EN-US;292063

Public WithEvents myOlItems As Outlook.Items

Public Sub Application_Startup()
  Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub myOlItems_ItemAdd(ByVal Item As Object)
  If TypeName(Item) = "MailItem" Then
    Dim M As MailItem
    Set M = Item
    
    'PR_TRANSPORT_MESSAGE_HEADERS
    Header = M.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E")
    
    If (InStr(1, M.SenderEmailAddress, "lj_notify@livejournal.com") > 0) Then
      If ((InStr(1, Header, "kuzmen - LJ Comment") > 0) _
          And (InStr(1, M.Subject, "Comment you posted...") > 0) _
          And (InStr(1, M.Subject, "Comment you edited...") > 0)) Then
        M.UnRead = False
        M.Move Application.GetNamespace("MAPI").Folders.Item("DK").Folders.Item("Archive")
      Else
        M.Move _
        Application.GetNamespace("MAPI").Folders.Item("DK").Folders.Item("Inbox").Folders.Item("LJ")
      End If
    End If
  End If
End Sub
What it does is it moves my own comments into "Archive" folder and marks them as read, and moves everything else into "LJ" subfolder under "Inbox", without expanding "Inbox".

Enjoy.
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments