assign category (VBA)

Status
Not open for further replies.

soadfan

Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
How can i assign category on incoming emails based on received date?
For example odd dates> blue, even > red
 

soadfan

Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
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
 

soadfan

Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
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?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

soadfan

Member
Outlook version
Outlook 2013 64 bit
Email Account
Office 365 Exchange
its on top and i disabled stop disabling more rules on all rules. And it was single mail when failed
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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)
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That is the same as i am using - will let it run and see what happens.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
P VBA to assign category on calendar item does not work ?? why ?? Outlook VBA and Custom Forms 5
A Outlook 2010 - assign a color category to email Using Outlook 2
R Assign Categories "Round Robin" style but in a shared mailbox but on specific emails only Outlook VBA and Custom Forms 8
P Auto assign shared mailbox Outlook VBA and Custom Forms 1
D Assign categories to outgoing emails Outlook VBA and Custom Forms 0
F How to assign a task to a public task folder? Using Outlook 1
A How to assign the value returned by the regex execute function to a variable? Using Outlook 1
Diane Poremsky Assign one task to several people New Slipstick.com Articles 0
Diane Poremsky Assign an Email Account to an Outlook Contact New Slipstick.com Articles 0
E for Mac: Assign Task not available!? Using Outlook 1
E Outlook VBA to print attached Pdf to a fax printer and assign fax number Using Outlook 0
A Assign a unique number to every message I send Using Outlook 0
Z assign unique number email Using Outlook 8
T How to Assign Retention Tags for Notes Items in Exchange/Outlook 2010? Exchange Server Administration 0
L Can you use Exchange 2010 to control which users may or may not assign tasks to other users in Outlo Exchange Server Administration 2
N Assign Task from shared Task folder error Using Outlook 3
Q Don't have right permissions to assign "send as" rights in Exchange 2010 SP1 Exchange Server Administration 7
I Outlook 2010 Archiving Assign Policy Greyed out Using Outlook 1
C How do you assign a color to emails that are only colorized if received from a specific person? Using Outlook 2
F Any way to add emails to favourites or assign shortcuts to them? Using Outlook 5
M I have added an Assign Task button to a cutom group in the Tasks Ribbon. When I click on it I get a Using Outlook 3
P Can I Assign Outlook Tasks to a Public Folder? Using Outlook 1
P Can I Assign Put a Public Folder on a Tasks's Update List? Using Outlook 5
C Y i cannot assign service to the newly added EXCHANGE certificate? Exchange Server Administration 6
C How to assign certificate(s) to an CAS array? Exchange Server Administration 1
C how should i assign an SSL certificate to a CAS array? Exchange Server Administration 2
D Update List clears after sending to assign person. Using Outlook 1
D assign & accept tasks using an IMAP email system Using Outlook 2
M Re: Exchange 2010 Resource forest - How do you assign permissions to share linked mailboxes? Exchange Server Administration 3
M Exchange 2010 Resource forest - How do you assign permissions to share linked mailboxes? Exchange Server Administration 7
D Assign rbac to specific group does not take affect. Exchange Server Administration 15
L When I assign a group permissions to a public folder in exchange 2010 the members of the group don't Exchange Server Administration 6
B Exchaneg 2010 SP1 Possible Bug, Cannot create move to archive retention tag on inbox, but can create a new one and edit and assign inbox to it Exchange Server Administration 3
J Assign a signature by external or internal reciepents. Outlook VBA and Custom Forms 1
S assign task programmatically Outlook VBA and Custom Forms 2
C Cannot assign a task from a public folder? Outlook VBA and Custom Forms 4
C Assign To and CC list while using Redemption.dll library Outlook VBA and Custom Forms 10
C How to assign icon to a button in Outlook Add-in Outlook VBA and Custom Forms 1
bhamberg Contacts in a category Outlook VBA and Custom Forms 11
K Custom Category Colors Using Outlook 2
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
K Update Appointment category when changed in Excel Using Outlook 3
J Automatic color category according to variable domains Outlook VBA and Custom Forms 4
Diane Poremsky Category Color doesn't Display in Inbox New Slipstick.com Articles 0
Wolfkc Unwanted Category "Starred in Android" Using Outlook 6
M receive mail when appointment category changes and create task from appointment Outlook VBA and Custom Forms 0
N VBA Outlook reference to Excel and assigning category Outlook VBA and Custom Forms 13
A recover contact category assignments Using Outlook 4
A Grouping emails using "From" causes a None Category Using Outlook 5
J Outlook Rules not show Master Category List Using Outlook.com accounts in Outlook 4
Similar threads


















































Top