Setting Outlook Categories with VBA
Open up the vba editor (Tools->Macro->Visual Basic Editor). Add a new module and paste the following code in (edit to suit).
Then to add the sub as a toolbar button customise the toolbar in the normal way and choose the 'Macros' category in the left pane - all your applicable macros will appear in the right pane. You can just drag it to your toolbar.
If the button seems to do nothing your outlook security settings may not be allowing macros. See Office Macro Security Settings.
Public Sub TagArchived() Dim objOutlook As Outlook.Application Dim objInspector As Outlook.Inspector Dim strDateTime As String ' Instantiate an Outlook Application object. Set objOutlook = CreateObject("Outlook.Application") ' The ActiveInspector is the currently open item. Set objExplorer = objOutlook.ActiveExplorer ' Check and see if anything is open. If Not objExplorer Is Nothing Then' Get the current item. Dim arySelection As Object Set arySelection = objExplorer.Selection For x = 1 To arySelection.Count strCats = arySelection.Item(x).Categories If Not strCats = ""Then strCats = strCats & ","End If strCats = strCats & "archived" arySelection.Item(x).Categories = strCats arySelection.Item(x).Save Next x Else' Show error message with only the OK button. MsgBox "No explorer is open", vbOKOnly End If' Set all objects equal to Nothing to destroy them and ' release the memory and resources they take. Set objOutlook = Nothing Set objExplorer = Nothing End Sub
06:10 AM, 27 Oct 2006 by Mark Aufflick Permalink
I use a customized toolbar to tag emails using this code. Right now if it is already tagged "archive" and you run the archive macro again it will tag it as "archive" twice. What is the code for removing the tag if it is already set? Thanks
by Unregistered Visitor on 08/25/09
I have the same question. This thing is great, but it adds multiple categories to a single item. Any way to delete the old one first?
by Unregistered Visitor on 10/23/09
You are a prince among men
I am a PA for dozens of people and at this time of year I used to spend days (no exaggeration) adding all next years meetings, pay days, financial deadlines, school holidays etc to each calendar in turn. Then I discovered the outlook.hol file now I spend days reclassifying all the events so they show up in the right categories on everyone’s To Do lists! With a little bit of replication and tweaking I’ve done this thankless task in one afternoon. Thanks.
by Unregistered Visitor on 11/06/09
That's about the best rap my blog has gotten!
Glad to help :)
by Mark Aufflick on 11/12/09
To replace current categories or remove them...
If you want to replace the current category instead of removing them then delete these lines;
If Not strCats = "" Then strCats = strCats & "," End If strCats = strCats & "archived"and replace with this;
strCats = "archived"Of course you would replace "archived" with whatever category you please.
by Unregistered Visitor on 07/15/10
Error on recurring entries
Hello, I'm using this macro successfully for a while, but it gives me an error message on recurring meetings. Any suggestions to fix this? Thanks Pepijn
by Unregistered Visitor on 11/15/10
RE: Error on recurring meetings
I don't remember ever having a problem with recurring meetings (and goodness knows I've had a few!) Unfortunately (for you - fortunate for me :) I operate a full Apple workflow these days - not a Windows PC to be seen - so I haven't used any Outlook VBA for some time.
by Mark Aufflick on 11/16/10
Pop up once the category is been defined
We have a mailbox where we receive multiple requests from clients and these request are being distributed among our team as a task to be worked on. Now I just wanted to know that is it possible to have a popup on users machine when admin assigns any particular mail to that user. I mean once the Category has been set for any particular mail, assignee should get a pop up on his machine saying that "Mail Item1 has been assigned to you".
by Unregistered Visitor on 06/17/11
changed it to a callable procedure and modified it a bit so that the category is not duplicated
Sub SetCat(Text) Dim objOutlook As Outlook.Application Dim objInspector As Outlook.Inspector Dim strDateTime As String ' Instantiate an Outlook Application object. Set objOutlook = CreateObject("Outlook.Application") ' The ActiveInspector is the currently open item. Set objExplorer = objOutlook.ActiveExplorer ' Check and see if anything is open. If Not objExplorer Is Nothing Then ' Get the current item. Dim arySelection As Object Set arySelection = objExplorer.Selection For x = 1 To arySelection.count strCats = arySelection.Item(x).Categories If Not strCats = "" Then For i = 1 To Len(strCats) If Mid(strCats, i, Len(Text)) = Text Then NextFor = True Exit For End If Next i strCats = strCats & "," End If If NextFor = True Then NextFor = False GoTo NextX End If strCats = strCats & Text arySelection.Item(x).Categories = strCats arySelection.Item(x).Save NextX: Next x Else ' Show error message with only the OK button. MsgBox "No explorer is open", vbOKOnly End If ' Set all objects equal to Nothing to destroy them and ' release the memory and resources they take. Set objOutlook = Nothing Set objExplorer = Nothing End Sub
by Unregistered Visitor on 06/21/11
Thanks for fixing my problem!
I've been trying to do this for ages, and I have written a macro that works for single emails, but not for multiple emails. I've found out the problem was that I was missing: email.Save That's fixed things, thanks!
by Unregistered Visitor on 07/24/11
Similar but different
Hi, I was wondering if it was possible to do a very similar procedure but a little different. There is a shared inbox where multiple emails are sent to a central email address and cced to a specific person. What would be the code to automatically categorize the email to the cced person? Thank you.
by Unregistered Visitor on 09/20/11
Taking up less space
Hi All, I slightly modified this so as to reduce the size of the code when creating multiple tags. This has to be set as a global variable Dim TagName As String Then you create the tag you want Public Sub TagArchive() TagName = "Archive" Call TagVariable End Sub Then rename the master macro as TagVariable Then you replace strCats = strCats & "archived" with strCats = strCats & TagName Then you can make multiple tags and only take up 4 lines, so you don't have to scroll though heaps of code each time you take a look.
by Unregistered Visitor on 07/26/12
How can this be modified so that it toggles the category on/off, taking into account that multiple categories are likely to be present already. Also, it needs to work in Outlook's 'conversation' view when I have the top-level conversation item selected (not an actual message). I will be calling it from Outlook's quick-access toolbar via a shortcut. TYVM for any support you can provide. ^_^
by Unregistered Visitor on 07/25/13
guys this is actually very helful i am greatful to you this is actualy wonderful novos jogos de moto
by Unregistered Visitor on 10/28/14
this is super all over guys as i was thinking of it to be really of well info and great tactis indeed 200 calorie meal plans
by Unregistered Visitor on 10/29/14
Created with the specialised documents industry in purpose the 44\" schoolwide iPF825 outputs documents atlantic thing only a family of samples of the calibre of writing the imagePROGRAF module manipulate. if you need the driver printer, you can check at Canon imageprograf ipf825 Driver download Aesthetically, real slight is completely diverse from incompatible Epson dedicated danger printers; it\'s monovular bucket-and-handle communication of the PictureMate if you need the driver printer, you can check at epson picturemate pm235 driver download Naturally, it cannot stop a candela to the One\'s indulgent name and 4.7in, 1080p guide, object for a sub-£200 sound the give 500 is uncommonly glorious. Its shiny discolor plastic phrase is around off nicely by a color dirty take that surrounds the force and seamlessly encompasses the honor buttons on the right-hand urgency. if you need the gadgets info, you can check at htc desire 500 review specifications Using deain groundwork of 1 of the most favourite Mitsubishi SUV beginning referred to as GG - PHEV , the most recent procreation Pajero was present to circularise the populate runway high-powered hit - in organism if you need the last info about car automotive, you can check at Mitsubishi gg phev pajero review bilang untuk memasang iklan Adsense di diary, kita harus mendaftar adsensenya dari Blogger, tidak bisa dari youtube lagi if you need the last info update about technology, you can check at pengenalan google adsense echo kita PIXMA MG7570 picture the PIXMA bit & Photo fulfil with NFC susceptibility, which suggests users don't got to control urbane meshwork settings. Users can turn documents or... if you need more info about geophysics, you can check at Rahmat Punya Driver Printer Download
by Unregistered Visitor on 10/30/14
Should there be another persuasive post you can share next time, I’ll be surely waiting for it. available now
by Unregistered Visitor on 11/09/14
Blog commenting serviceGreat post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first”.
by Unregistered Visitor on 11/10/14
You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site. http://binary-options-reviews.com/text.php?lang=heb&id=4&sid=37
by ahmed raza on 11/11/14
Truthfully, your object is beside. My buddy just compared this advise beside pay to write college essay besides he was satisfied. Someday, he designed hellos confess review for hellos body.
by Unregistered Visitor on 11/11/14
I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here.dentist 33414 Big thumbs up for making such wonderful blog page!
by Unregistered Visitor on 11/11/14
To mine memory, you selected to scratch an educational courier. I was so impressed whereas I discovered delivering supreme essay writing services further made an sequel there. The primary objective is because protected from false employs.
by Unregistered Visitor on 11/12/14
Kid Icarus is a mixture of platform games, action and shooter released in 1986. You play Pit, the angel helped by the goddess of light Palutena, to explore dungeons to bring the hand on the three sacred treasures, to hope to beat Medusa Goddess of Darkness. emulator 3ds
by Unregistered Visitor on 11/13/14
'The Legend of Zelda: Majora Mask' è essere rifatto per il Nintendo 3DS Nintendo ha annunciato che il suo successo N64 gioco 'The Legend of Zelda: Majora Emulatore 3DS Mask' è eccitato essendo rifatto per il portatile 3DS. Il gioco originale è stato rilasciato nel 2000 e ...
by Unregistered Visitor on 11/14/14
Wonderful, what a blog it is! This website presents valuable information to us, keep it up. rebel mouse forex trendy
by Unregistered Visitor on 11/21/14
These days education become so easy for all students in whole world due to top quality educational networks. I am glad to share something about online education, because i have some great idea to boost you education. Check rushmyessays professional writing service online and get free demos as well. Our company provides money back guarantee as well so don't think about any internet scam at all.
by Unregistered Visitor on 11/21/14
Good Post, I am a big believer in posting comments on sites to let the blog writers know that theyâ€™ve added something advantageous to the world wide web! https://www.rebelmouse.com/restoremyvisiontodayreviews
by Unregistered Visitor on 11/25/14
nice to be here
I just want to let you know that I just check out your site and I find it very interesting and informative. I am really impressed with this and I hope that more stuff like this will be given to us Fifa 15 Coins
by Unregistered Visitor on 11/27/14