After quick research i came up with this (im not sure it's most elegant/optimized way):
Code:
Public Sub DateBasedCategories(itm As Outlook.MailItem)
Dim dateFormat
dateFormat = Format(itm.ReceivedTime, "dd")
If dateFormat Mod 2 = 1 Then
itm.Categories = "date.odd"
itm.Save
Else
itm.Categories = "date.even"
itm.Save
End If
End Sub
I did notice that it won't work for some emails (with attachments mostly) when they arrive. But after that if i run rule manually it assign category, any ideas?
That is pretty much how i would have said to do it. will test it to see how it works here.
Do you get many messages in at one time? if too many come at once, the rule may fail on some - it's possible that the ones with attachments are larger and the rule skips them to deal with others... also if you use other rules, put this at the top and don't use 'stop processing' so all messages are categorized.
I wasn't able to repro it with a 2 mb attach, which isn't all that surprising for a short, quickie test (although it took forever for it to arrive and both accounts are in the same office 365 tenant.) I'll need to let it run a bit longer and see if i can repro.
It was actually interesting to watch the folder - the message arrived and several seconds (probably 2 or 3 but it seemed longer) passed before the category was applied. Not sure if it was due to the message size or was due to other issues (that machine seems unusually slow today).
The rule has no conditions, only the run a script action? (so it applies to all mail)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.