Outlook Rules - morfizm
|Aug. 24th, 2009 10:02 am 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"
Public WithEvents myOlItems As Outlook.Items
Public Sub Application_Startup()
Set myOlItems = Outlook.Session.GetDefaultFolder(olFolderInbox).Items
Private Sub myOlItems_ItemAdd(ByVal Item As Object)
If TypeName(Item) = "MailItem" Then
Dim M As MailItem
Set M = Item
Header = M.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001E")
If (InStr(1, M.SenderEmailAddress, "email@example.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
End SubWhat 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.3 comments - Leave a comment
|Date:||September 17th, 2009 08:06 pm (UTC)|| |
Why use Instr?
Why use Instr to check for your email address when you can just do it directly?
Also, it looks like you are checking for "Comment you posted..." AND "Comment you edited..." in the Subject.
|Date:||September 17th, 2009 08:09 pm (UTC)|| |
Re: Why use Instr?
Sorry, what I meant was, why are you checking for your email address, when by definition the email has to be for you since its in your Inbox?
|Date:||September 17th, 2009 09:12 pm (UTC)|| |
Re: Why use Instr?
1. Why Instr: smaller number of concepts -> simpler code, and since the result will almost always be the same (I can hardly imagine how one e-mail can be a substring of another), why not to use Instr? Also, it'll take smaller code change if I want to check for e-mail in, say, Header, instead of SenderEmailAddress. For Header case I'll have to use Instr.
2. I am subscribed for both type of LJ comments: that I leave myself, and that somebody leave for me. The subject strings you've mentioned are for type 1 only.
3. On a side note, my check is somewhat redundant, because "kuzmen - LJ Comment" alone may be enough. Let's say I have more checks for demonstration purposes :)