DonationCoder.com Software > Post New Requests Here
IDEA - AHK script - Outlook'03 Apply Category Label
PRICET:
perfect - many thanks
PRICET:
Hi again ... wonder if you can help again .....
I have code that will move a mail message ot a specifuc folder for me
I also have your code that you gave me to assign a category to the email through the use of a button on the toolbar. Both work great
Now I want to combine both bits of code into one button so that if I want to categorize and email and move it to a designated folder in click I can do this with a button on the toolbar.
The code I have for moving mail to a folder is
Sub Archive_Move_ToFolder()
On Error Resume Next
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objNS.Folders.Item("Personal Folders").Folders.Item("Archive")
'Assume this is a mail folder
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER"
End If
If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Move objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
this is in the "ThisOutlooksession"
then I have you code in modules ... how I can run your code to assign the category and then call the other to move the email to the folder?
Thanks
PRICET:
Hi again ... all the functionality you have provided me works fantastic, many thanks!!!
New challenge - I have created the code to store my most used categories and then have buttons on the toolbar to populate each of the categories I want to assign. This works great.
However - if I change my list of categories as a new one becomes "more used" than another I currently go into Visualbasic editor, modify the code, change the category and then chang the text on the button.
OK for me being IT savvy but for "normal users" it is a bit scary going into visual basic editor.
Is there any way to create some sort of dialogue box which would show them the list if assignmnets they have defined and then asking them which one they want to change?
So I have this code for each of my categories.
Private Const MY_CUSTOM_CATEGORIES__ = ""
Private Const MY_CUSTOM_CATEGORIES_1_ = "CRM"
Private Const MY_CUSTOM_CATEGORIES_2_ = "NA"
Private Const MY_CUSTOM_CATEGORIES_3_ = "CEEMEA"
Private Const MY_CUSTOM_CATEGORIES_4_ = "RU"
Private Const MY_CUSTOM_CATEGORIES_5_ = "BI"
Private Const MY_CUSTOM_CATEGORIES_6_ = "H2R"
Private Const MY_CUSTOM_CATEGORIES_7_ = "SA"
Private Const MY_CUSTOM_CATEGORIES_8_ = "CEN"
Private Const MY_CUSTOM_CATEGORIES_9_ = "CES"
Private Const MY_CUSTOM_CATEGORIES_10_ = "HHIT"
Private Const MY_CUSTOM_CATEGORIES_11_ = "SIGMA"
Private Const MY_CUSTOM_CATEGORIES_12_ = "TU"
Private Const MY_CUSTOM_CATEGORIES_13_ = "ME"
Private Const MY_CUSTOM_CATEGORIES_14_ = "Finance"
Private Const MY_CUSTOM_CATEGORIES_15_ = "SP"
Private Const MY_CUSTOM_CATEGORIES_16_ = "HIK"
Private Const MY_CUSTOM_CATEGORIES_17_ = "FCPA"
Private Const MY_CUSTOM_CATEGORIES_18_ = "Read"
If I want to change MY_CUSTOM_CATEGORIES_1_ = "CRM" to MY_CUSTOM_CATEGORIES_1_ = "New category" could it be made simpler?
Thoughts or dreaming?
Thanks Tim
r0bertdenir0:
Well now you're talking about making a pretty UI to control this thing & that's the tedious stuff. :-\
Cos thinking up a good UI & all the weird things a user can do 2 screw it up is the hardest bit of programming...
OK, here's what I'm thinking:
Instead of categories fixed in yr code, you need to actually save yr categories to disk & give the user some UI to modify them (add, remove, edit) & also select the categories.
Seems like you basically gonna create a custom categories manager. :tellme:
I'll guide you on yr way & if you have any questions just ask back here.
Here's wat I wud do
1. Save the categories using either the registry or a file. You can find lotsa VB code on the net to save settings to an xml file & that's a gud way 2 go so you can move settings between machines. Otherwise use the registry (SaveSetting / GetSetting)
2. First get it working by copying yr categories to yr file/registry & see if you can read them properly each time.
3. On Outlook shutdown, delete the custom toolbar to ensure a clean startup.
4. On Outlook startup, recreate the toolbar, then read the settings & create the buttons for each item.
5. When you read the settings, I would suggest writing them to a VB Collection - by putting the category as an Item's collection Key & also into the Tag field of the related toolbar button, you can easily track which button the user is clicking & retrieve from the collection.
6. Now that you have it working from file/registry with fixed number of categories, you'll want to create a UI so users can add/remove their own categories.
7. Just make this with a simple UserForm & a listbox, with Add, Delete, OK buttons. This will allow users to modify the categories. When the user clicks OK, you'll have 2 delete the toolbar & recreate it just like at startup so user changes are implemented. But that will just be a simple matter to call yr Shutdown & Startup code you already implemented.
8. Perhaps instead of buttons 4 each category which can get cluttered, use the dialog you made to add/remove to also set the categories by using a checked-listbox?
This would be a non-modal form, and as the user moves between different mail items - the form would just show the categories for the active mail item. The checked-listbox would be used to add/remove categories from the active item & also add/remove global categories from the list.
This could be made a pretty slick interface.
If you do this then remember that besides adding yr categories to the listbox, you must also add any existing categories from that mail item which may have come from another person.
This shud set you off in the ryt direction - any questions or other ideas just ask.
PRICET:
Hi - many thanks for your thoughts!!!
I think this is what I am looking for .... but may be out of my league to create.
I found the entry in the registry that stores my categories - HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Categories
I can export this registry entry and it creates
[HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Categories]
"MasterList"=hex:41,00,63,00,63,00,6f,00,75,00,6e,00,74,00,20,00,6d,00,67,00,\
74,00,3b,00,42,00,65,00,72,00,6c,00,69,00,6e,00,3b,00,42,00,49,00,3b,00,42,\
00,75,00,64,00,67,00,65,00,74,00,73,00,3b,00,42,00,75,00,73,00,69,00,6e,00,\
65,00,73,00,73,00,3b,00,43,00,44,00,4d,00,3b,00,43,00,45,00,45,00,4d,00,45,\
00,41,00,3b,00,43,00,45,00,4e,00,3b,00,43,00,45,00,53,00,3b,00,43,00,6f,00,\
6d,00,65,00,74,00,3b,00,63,00,6f,00,6d,00,70,00,6c,00,69,00,61,00,6e,00,63,\
00,65,00,3b,00,43,00,52,00,4d,00,3b,00,63,00,7a,00,72,00,3b,00,44,00,65,00,\
6c,00,69,00,76,00,65,00,72,00,79,00,3b,00,44,00,65,00,76,00,65,00,6c,00,6f,\
00,70,00,3b,00,44,00,4b,00,3b,00,44,00,4b,00,2d,00,46,00,69,00,6e,00,61,00,\
6e,00,63,00,65,00,3b,00,45,00,44,00,57,00,3b,00,45,00,4d,00,3b,00,65,00,6d,\
00,61,00,69,00,6c,00,20,00,70,00,72,00,6f,00,63,00,65,00,73,00,73,00,3b,00,\
45,00,6d,00,65,00,72,00,67,00,65,00,3b,00,45,00,53,00,49,00,3b,00,65,00,53,\
00,4d,00,54,00,3b,00,45,00,78,00,70,00,20,00,72,00,65,00,70,00,6f,00,72,00,\
74,00,73,00,3b,00,46,00,43,00,50,00,41,00,3b,00,46,00,49,00,3b,00,46,00,69,\
00,6e,00,61,00,6e,00,63,00,65,00,3b,00,46,00,6f,00,6f,00,74,00,62,00,61,00,\
6c,00,6c,00,3b,00,47,00,6f,00,61,00,6c,00,73,00,2f,00,4f,00,62,00,6a,00,65,\
00,63,00,74,00,69,00,76,00,65,00,73,00,3b,00,47,00,4f,00,4f,00,44,00,3b,00,\
47,00,54,00,53,00,3b,00,48,00,32,00,52,00,3b,00,48,00,65,00,6c,00,70,00,64,\
00,65,00,73,00,6b,00,3b,00,48,00,48,00,49,00,54,00,3b,00,48,00,48,00,49,00,\
54,00,20,00,54,00,43,00,3b,00,48,00,49,00,4b,00,3b,00,48,00,6f,00,75,00,73,\
00,65,00,3b,00,48,00,52,00,3b,00,49,00,45,00,3b,00,49,00,46,00,4d,00,3b,00,\
49,00,6e,00,6e,00,6f,00,76,00,61,00,74,00,69,00,6f,00,6e,00,3b,00,49,00,6e,\
00,74,00,72,00,61,00,6e,00,65,00,74,00,3b,00,49,00,54,00,3b,00,49,00,54,00,\
4f,00,4d,00,3b,00,6b,00,61,00,69,00,7a,00,65,00,6e,00,3b,00,4c,00,65,00,67,\
00,61,00,6c,00,3b,00,4d,00,61,00,67,00,53,00,63,00,61,00,6e,00,64,00,3b,00,\
4d,00,61,00,73,00,74,00,65,00,72,00,20,00,44,00,61,00,74,00,61,00,3b,00,4d,\
00,43,00,43,00,3b,00,4d,00,45,00,3b,00,4d,00,65,00,6e,00,74,00,6f,00,72,00,\
3b,00,4d,00,49,00,44,00,41,00,53,00,3b,00,4d,00,4d,00,44,00,3b,00,4d,00,52,\
00,4c,00,3b,00,4e,00,41,00,3b,00,4e,00,43,00,4d,00,3b,00,4e,00,4f,00,3b,00,\
6f,00,6e,00,6c,00,69,00,6e,00,65,00,3b,00,50,00,65,00,72,00,73,00,6f,00,6e,\
00,61,00,6c,00,3b,00,70,00,6f,00,3b,00,50,00,6f,00,72,00,74,00,66,00,6f,00,\
6c,00,69,00,6f,00,3b,00,50,00,72,00,6f,00,6a,00,65,00,63,00,74,00,20,00,73,\
00,68,00,75,00,74,00,64,00,6f,00,77,00,6e,00,3b,00,52,00,65,00,61,00,64,00,\
3b,00,52,00,49,00,53,00,4c,00,54,00,3b,00,52,00,4d,00,43,00,3b,00,52,00,75,\
00,73,00,3b,00,53,00,41,00,3b,00,53,00,41,00,53,00,20,00,54,00,72,00,61,00,\
76,00,65,00,6c,00,3b,00,53,00,63,00,61,00,6e,00,64,00,20,00,49,00,54,00,3b,\
00,53,00,65,00,61,00,74,00,74,00,6c,00,65,00,3b,00,53,00,49,00,47,00,4d,00,\
41,00,3b,00,53,00,69,00,67,00,6d,00,61,00,20,00,63,00,6f,00,6d,00,6d,00,3b,\
00,53,00,69,00,67,00,6d,00,61,00,20,00,74,00,72,00,61,00,69,00,6e,00,69,00,\
6e,00,67,00,3b,00,53,00,49,00,50,00,3b,00,53,00,50,00,3b,00,53,00,70,00,6f,\
00,6e,00,73,00,6f,00,72,00,3b,00,53,00,74,00,72,00,61,00,74,00,65,00,67,00,\
69,00,65,00,73,00,3b,00,53,00,57,00,3b,00,54,00,65,00,61,00,6d,00,20,00,53,\
00,69,00,74,00,65,00,3b,00,54,00,69,00,6d,00,65,00,20,00,6d,00,67,00,74,00,\
3b,00,54,00,72,00,61,00,69,00,6e,00,69,00,6e,00,67,00,3b,00,54,00,72,00,61,\
00,76,00,65,00,6c,00,3b,00,54,00,72,00,65,00,64,00,61,00,70,00,3b,00,54,00,\
55,00,3b,00,55,00,53,00,20,00,48,00,6f,00,6c,00,69,00,64,00,61,00,79,00,3b,\
00,56,00,61,00,63,00,61,00,74,00,69,00,6f,00,6e,00,20,00,6d,00,67,00,74,00,\
3b,00,56,00,69,00,64,00,65,00,6f,00,20,00,43,00,6f,00,6e,00,66,00,65,00,72,\
00,65,00,6e,00,63,00,65,00,3b,00,57,00,65,00,62,00,3b,00,00,00
But now I have no idea about how to implement the next steps ....
Are you saying that the new button on my toolbar would read this file to get the category?
Sorry ... but need some help
Thanks in advance
Tim
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version