Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 05, 2016, 08:57:00 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: IDEA - AHK script - Outlook'03 Apply Category Label  (Read 14047 times)

wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
IDEA - AHK script - Outlook'03 Apply Category Label
« on: April 15, 2009, 01:01:18 PM »
Would like to use AHK script to assign a Category label called "1 - Client - sent to"
to an email that is open and/or to one that is merely selected (but not open) in an email folder.

Is this doable? Can you give me some guidance?


Thank you,
weg

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #1 on: April 25, 2009, 02:35:02 PM »
Yes it's doable.
But I think AHK is the second choice in this case - but that's just going on yr post.
If you do this with AHK you'd basically be simulating user interaction & filling in the relevant dialogs.
That's fine but Office apps are notorious for undocumented features & the 1st I noticed was Outlook seemed to hang when I first entered a new Category & then worked fine. :tellme:

In any case, I think a better way for you to go is to use VBA in Outlook.
It's a simple matter to write a macro that will write the data to the Categories field of a MailItem.
Then create a custom toolbar & a button linked to the macro. Whenever you need to, just click the button & yr category is set!
You can even put a loop in the macro so that you can select multiple items & set the Category for all items at once.

It's actually just half a page of code so I'll post it for you in a little bit.

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #2 on: April 25, 2009, 04:47:46 PM »
Ok, this is what I came up with - hope it's what you're looking for.
Open the VBA editor in Outlook (Alt F11), click the Insert menu & click Module & paste this code into the new module.
Then open the Immediate window (Ctrl G), type AddCustomCategoriesToolbar & hit Enter.

(You can also open the ThisOutlookSession object & run AddCustomCategoriesToolbar from the Application_Startup event.)

One more thing, you'll see the category added but in brackets the note (not in Master Category List)
The category is still associated with the email.
Outlook 2003 doesn't give programmatic access to the Master Category List, so if you wanna get rid of that side-note, add it yrself via the Categories dialog & you won't have any problems.
But as far as I can make out it's just cosmetic.

Code: Visual Basic [Select]
  1. Option Explicit
  2.  
  3. Private Const MY_CUSTOM_TOOLBAR__ = "Virtua"
  4. Private Const MY_CUSTOM_CATEGORIES_BUTTON__ = "Set Categories"
  5. Private Const MY_CUSTOM_CATEGORIES__ = "1 - Client - sent to"
  6.  
  7.  
  8. Public Sub AddCustomCategoriesToolbar()
  9. On Error Resume Next
  10. Dim oNewCmdBar As CommandBar
  11. Dim oNewButton As CommandBarButton
  12.    
  13.     '**first check if toolbar exists
  14.    Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
  15.     '**otherwise create it
  16.    If (oNewCmdBar Is Nothing) Then
  17.         Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Add(MY_CUSTOM_TOOLBAR__)
  18.     End If
  19.    
  20.     '**first check if button exists
  21.    Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
  22.     '**otherwise create it
  23.    If (oNewButton Is Nothing) Then
  24.         Set oNewButton = oNewCmdBar.Controls.Add(msoControlButton)
  25.     End If
  26.     '**set the caption & macro to run
  27.    oNewButton.Caption = MY_CUSTOM_CATEGORIES_BUTTON__
  28.     oNewButton.OnAction = "CustomActions_Categories"
  29.    
  30.     '**by default they are created invisible
  31.    oNewButton.Visible = True
  32.     oNewCmdBar.Visible = True
  33.    
  34. End Sub
  35.  
  36.  
  37. Private Sub CustomActions_Categories()
  38. On Error Resume Next
  39. Dim oItem As Object
  40. Dim oNewCmdBar As CommandBar
  41. Dim oNewButton As CommandBarButton
  42.  
  43.     Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
  44.     Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
  45.    
  46.     oNewButton.Caption = "Working..."
  47.     DoEvents
  48.    
  49.     '**loop thru selected items
  50.    For Each oItem In ActiveExplorer.Selection
  51.         '**set their categories if they have the property
  52.        oItem.Categories = MY_CUSTOM_CATEGORIES__
  53.         '**save our change
  54.        If (Err = 0) Then
  55.             oItem.Save
  56.         End If
  57.        
  58.     Next oItem
  59.  
  60.     oNewButton.Caption = MY_CUSTOM_CATEGORIES_BUTTON__
  61.  
  62. End Sub

wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #3 on: April 27, 2009, 12:28:07 PM »
r0bertdenir0 - Thank so much for taking the time to reply and work this up.

What is the trick to copying the code and having the line breaks correct?
When I paste, it's essentially all on one line.

weg

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #4 on: April 27, 2009, 12:47:36 PM »
i dont get the all-on-one-line problem, BUT i also have trouble copying and pasting the code in the highlighter box.. let me see if there is some way to fix that..

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #5 on: April 29, 2009, 08:00:34 AM »
It was an interesting problem.
Hope it does what you're looking 4. :D

wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #6 on: April 29, 2009, 08:09:59 AM »
Again, I can't really use it without the code being formatted correctly.
It's not pasting properly. Everything is running together on one or two lines.

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 7,986
    • View Profile
    • Dales Computer Services
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #7 on: April 29, 2009, 09:22:29 AM »
Will this do? (I just removed the code tags).

For future reference a quick way to do that is to hit 'Quote' as if replying and then just copy the quted contents from the message editor. That is plain text.



Option Explicit

Private Const MY_CUSTOM_TOOLBAR__ = "Virtua"
Private Const MY_CUSTOM_CATEGORIES_BUTTON__ = "Set Categories"
Private Const MY_CUSTOM_CATEGORIES__ = "1 - Client - sent to"


Public Sub AddCustomCategoriesToolbar()
On Error Resume Next
Dim oNewCmdBar As CommandBar
Dim oNewButton As CommandBarButton
   
    '**first check if toolbar exists
    Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
    '**otherwise create it
    If (oNewCmdBar Is Nothing) Then
        Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Add(MY_CUSTOM_TOOLBAR__)
    End If
   
    '**first check if button exists
    Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
    '**otherwise create it
    If (oNewButton Is Nothing) Then
        Set oNewButton = oNewCmdBar.Controls.Add(msoControlButton)
    End If
    '**set the caption & macro to run
    oNewButton.Caption = MY_CUSTOM_CATEGORIES_BUTTON__
    oNewButton.OnAction = "CustomActions_Categories"
   
    '**by default they are created invisible
    oNewButton.Visible = True
    oNewCmdBar.Visible = True
   
End Sub


Private Sub CustomActions_Categories()
On Error Resume Next
Dim oItem As Object
Dim oNewCmdBar As CommandBar
Dim oNewButton As CommandBarButton

    Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
    Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
   
    oNewButton.Caption = "Working..."
    DoEvents
   
    '**loop thru selected items
    For Each oItem In ActiveExplorer.Selection
        '**set their categories if they have the property
        oItem.Categories = MY_CUSTOM_CATEGORIES__
        '**save our change
        If (Err = 0) Then
            oItem.Save
        End If
       
    Next oItem

    oNewButton.Caption = MY_CUSTOM_CATEGORIES_BUTTON__

End Sub


« Last Edit: April 29, 2009, 09:24:20 AM by Carol Haynes »

wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #8 on: April 29, 2009, 11:19:13 AM »
Carol,

Easy/perfect solution. I will give it a shot and try working
with the VBA.

Thanks,
weg

wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #9 on: April 29, 2009, 11:31:44 AM »
r0bertdenir0,

Is there a simple change in the VBA code that I can make so that
it will assign the category whether the items are selected in the
ActiveExplorer.Selection or the target email is open for viewing or editing?

I can add a command button to the message dialog that would call
the assign category subroutine and not go through the create toolbar routine.
Make sense?

Thanks,
weg
« Last Edit: April 29, 2009, 01:22:36 PM by wideeyedguy »

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #10 on: April 29, 2009, 02:16:33 PM »
I understand wat you mean about changing an open item. I'll post the macro 2 do that in a bit let me just test it.
How wud you create the command button & link it 2 the macro?
I mostly work in Excel which handles macros more easily so I'm curious 2 know how you link them.

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #11 on: April 29, 2009, 02:54:54 PM »
Try this.
The CustomActions_Categories() function will first check if there is an Inspector open & only if there isn't, look at the ActiveExplorer.
The other change I made was 2 make this function Public so you can call it like a macro from yr command button.
But let me know how you did that without a CommandBar - if you're using a VBA UserForm or you're editing the MessageForm design in Outlook.
Especially if it's the latter cos I've neva done that so I'd like 2 know! :D

But my advice wud be 2 keep the toolbar in the main Outlook window as well as yr CommandButton in the mail inspector.
Cos there will be times when you don't wanna open every item but just select half yr mailbox & hit go.


Quote
Option Explicit

Private Const MY_CUSTOM_TOOLBAR__ = "Virtua"
Private Const MY_CUSTOM_CATEGORIES_BUTTON__ = "Set Categories"
Private Const MY_CUSTOM_CATEGORIES__ = "1 - Client - sent to"


Public Sub AddCustomCategoriesToolbar()
On Error Resume Next
Dim oNewCmdBar As CommandBar
Dim oNewButton As CommandBarButton
   
    '**first check if toolbar exists
    Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
    '**otherwise create it
    If (oNewCmdBar Is Nothing) Then
        Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Add(MY_CUSTOM_TOOLBAR__)
    End If
   
    '**first check if button exists
    Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
    '**otherwise create it
    If (oNewButton Is Nothing) Then
        Set oNewButton = oNewCmdBar.Controls.Add(msoControlButton)
    End If
    '**set the caption & macro to run
    oNewButton.Caption = MY_CUSTOM_CATEGORIES_BUTTON__
    oNewButton.OnAction = "CustomActions_Categories"
   
    '**by default they are created invisible
    oNewButton.Visible = True
    oNewCmdBar.Visible = True
   
End Sub


Public Sub CustomActions_Categories()
On Error Resume Next
Dim oItem As Object
Dim oNewCmdBar As CommandBar
Dim oNewButton As CommandBarButton
   
    '**first check if a single mail item is open 4 viewing & deal with that case first
    If (ActiveWindow.Class = ActiveInspector.Class) Then
        Set oItem = ActiveInspector.CurrentItem
        '**set their categories if they have the property
        oItem.Categories = MY_CUSTOM_CATEGORIES__
       
        '**we don't save in this case, this allows you 2 cancel changes you made 2 the item
        '**you'll be asked 2 save when you close - I think this is expected behavior
        '**if you disagree uncomment line below but keep in mind you may have made other changes 2 the item which will also be saved
        'oItem.Save
       
        Exit Sub
    End If
   
   
    Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
    Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
   
    oNewButton.Caption = "Working..."
    DoEvents
   
    '**loop thru selected items
    For Each oItem In ActiveExplorer.Selection
        '**set their categories if they have the property
        oItem.Categories = MY_CUSTOM_CATEGORIES__
        '**save our change
        If (Err = 0) Then
            oItem.Save
        End If
       
    Next oItem

    oNewButton.Caption = MY_CUSTOM_CATEGORIES_BUTTON__

End Sub


wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #12 on: April 29, 2009, 03:47:33 PM »
Almost there!
Now, the code is not setting the category in the ActiveExplorer.Selection with an email selected
but no open.

The category is working when I have an email open (ActiveInspector.CurrentItem) and
select the command button which activates the CustomActions_Categories() subroutine.

As far as adding the command button, all I'm doing is going in to Customize Toolbar mode
within either the email "Inspector" open to add to that form or with just the Outlook GUI
and adding it to an existing toolbar or one of my custom tb's.

I select the Macro category and there in the list are the two macros.
So, actually, all I need is the macro that activates the changing or the setting
of the Category label. But, need it to work in both circumstances that we've discussed.

What is this section intended to accomplish?
Set oNewCmdBar = Application.ActiveExplorer.CommandBars.Item(MY_CUSTOM_TOOLBAR__)
    Set oNewButton = oNewCmdBar.Controls.Item(MY_CUSTOM_CATEGORIES_BUTTON__)
   
    oNewButton.Caption = "Working..."
    DoEvents
If the button caption is supposed to change during the macro, it's apparently too fast
to really display that. I'm struggling quite a bit with learning enough about VBA to
even be dangerous.

Thank you,
weg

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #13 on: April 29, 2009, 04:07:34 PM »
OK. I'm just adding the command bars programmatically & you're doing it thru the user interface.
That's cool.
Yes the text of the button does change while it's working but you wud only notice it when you have many items selected - otherwise 2 fast as you noticed.
Since you comfy adding the command buttons yrself & linking them, I'll show you how 2 just have a macro with none of the other stuff.
I don't understand about you saying it don't work when the a mail is selected but not open cos I tested that here & it worked.

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #14 on: April 29, 2009, 04:38:55 PM »
Here's a simplified macro  - no command bar stuff, you doing that yrself.
The reason why it was not setting the category when no inspector was open are the lines:
Quote
If (Err = 0) Then
    oItem.Save
End If
Sum items don't support categories, like meetings but they can be in yr inbox so they cause an error which we have 2 ignore.
The problem is when there is no inspector open, the inspector code:
Quote
If (ActiveWindow.Class = ActiveInspector.Class) Then
generates an error, "Object not set" becos without an open inspector ActiveInspector is Nothing & we can't call ActiveInspector.Class. >:(
Altho the code inside the IF statement is not run, the IF statement itself causes a runtime error.
This error then gets carried down 2 the
Quote
If (Err = 0) Then
& so the category is set on the item, but the change is not saved. >:(

Hope I have you sufficiently confused :D


Quote
Option Explicit

Private Const MY_CUSTOM_CATEGORIES__ = "1 - Client - sent to"


Public Sub SetCustomCategoriesForItems()
On Error Resume Next
Dim oItem As Object
   
    Err.Clear
    '**first check if a single mail item is open 4 viewing & deal with that case first
    If (ActiveWindow.Class = ActiveInspector.Class) Then
        '**get the item we're viewing
        Set oItem = ActiveInspector.CurrentItem
        '**set their categories if they have the property
        oItem.Categories = MY_CUSTOM_CATEGORIES__
    End If
   
    If (ActiveWindow.Class = ActiveExplorer.Class) Then
        '**loop thru selected items
        For Each oItem In ActiveExplorer.Selection
            '**clear the error buffer here in case the are mail items mixed with other items in folder - also the call to ActiveInspector.Class above has caused an error
            Err.Clear
            '**set their categories if they have the property
            oItem.Categories = MY_CUSTOM_CATEGORIES__
            '**save our change
            If (Err = 0) Then
                oItem.Save
            End If
           
        Next oItem
   
    End If
   
End Sub


wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #15 on: April 29, 2009, 05:50:35 PM »
As they say in Swahili - you are a beautiful person!

Jiffy spiffy; works perfectly.
I just reattached new command buttons pointing to
the new macro and done.

Sorry to get you so involved in creating the other code.

How can I unload the 'Virtua' toolbar from Outlook's 'memory'?
It's still showing up in available toolbars even though I've deleted
it off of the GUI.

Thanks.

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #16 on: April 30, 2009, 07:41:12 AM »
If it's still available then I don't think you deleted it from the GUI, maybe just closed it?
Open the Customize Toolbars dialog, in the list of toolbars, click on Virtua & then click the Delete button on the right. :Thmbsup:

wideeyedguy

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 28
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #17 on: April 30, 2009, 10:33:56 AM »
Thank you.

We're done with this one.

weg

PRICET

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #18 on: June 17, 2009, 03:34:21 PM »
If it's still available then I don't think you deleted it from the GUI, maybe just closed it?
Open the Customize Toolbars dialog, in the list of toolbars, click on Virtua & then click the Delete button on the right. :Thmbsup:
Hi - I like this code. I created a couple of buttons on the Outlook toolbar and created 2 macros for 2 categories I use regularily.

However ..... if I hit one botton it inserts the category I coded. If I then hit the other button it overwrites the first category. Is there an aasy way of inserting the second category after ","  i.e Category1, Category 2

Thanks

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #19 on: June 18, 2009, 10:09:25 AM »
Try this

Quote
Option Explicit

Private Const MY_CUSTOM_CATEGORIES_1_ = "1 - Client - sent to"
Private Const MY_CUSTOM_CATEGORIES_2_ = "2 - Supplier"
Private Const MY_CUSTOM_CATEGORIES_3_ = "Test Category"


Public Sub Button1()
    SetCustomCategoriesForItems MY_CUSTOM_CATEGORIES_1_
End Sub

Public Sub Button2()
    SetCustomCategoriesForItems MY_CUSTOM_CATEGORIES_2_
End Sub

Public Sub Button3()
    SetCustomCategoriesForItems MY_CUSTOM_CATEGORIES_3_
End Sub



Private Sub SetCustomCategoriesForItems(NewCategory As String)
On Error Resume Next
Dim oItem As Object
   
    Err.Clear
    '**first check if a single mail item is open 4 viewing & deal with that case first
    If (ActiveWindow.Class = ActiveInspector.Class) Then
        '**get the item we're viewing
        Set oItem = ActiveInspector.CurrentItem
        '**set their categories if they have the property
        oItem.Categories = AddCategoryToCategories(NewCategory, oItem.Categories)
    End If
   
    If (ActiveWindow.Class = ActiveExplorer.Class) Then
        '**loop thru selected items
        For Each oItem In ActiveExplorer.Selection
            '**clear the error buffer here in case the are mail items mixed with other items in folder - also the call to ActiveInspector.Class above has caused an error
            Err.Clear
            '**set their categories if they have the property
            oItem.Categories = AddCategoryToCategories(NewCategory, oItem.Categories)
            '**save our change
            If (Err = 0) Then
                oItem.Save
            End If
           
        Next oItem
   
    End If
   
   
End Sub


Private Function AddCategoryToCategories(NewCategory As String, ExistingCategories As String) As String
Dim avExistingCategories
Dim vCategory

    If (ExistingCategories = "") Then   '**1st category is easy
        AddCategoryToCategories = NewCategory
       
    Else
       
        '**split the category list
        avExistingCategories = Split(ExistingCategories, ",")
        '**search 4 match - this is slower but more robust than using InStr to search, but unless you hundreds of items with dozens of categories, you won't feel it
        For Each vCategory In avExistingCategories
            If (NewCategory = Trim(vCategory)) Then
                AddCategoryToCategories = ExistingCategories
                Exit Function
            End If
        Next vCategory
       
        '**append the new item since it doesn't exist
        AddCategoryToCategories = ExistingCategories & ", " & NewCategory
   
    End If
   
End Function


PRICET

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #20 on: June 18, 2009, 10:59:30 AM »
This is just fantastic - it transforms my use of Outlook.

Here is another request , if you are up to it ...

I would like to have a second "send" button in outlook.

the second "send" when you click would first bring up the categories dial-up box so you can select categories to assign to an outgoing mail, once you hit OK it would send the mail with the categories assigned.

I would still keep the traditional "send" but have another button with , for example "Send - cats"

Possible or am I dreaming ...?

Many thanks, Tim

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #21 on: June 19, 2009, 03:05:27 AM »
Try adding this procedure to the previous code.
You can try opening a mail item & adding a macro button that links to this procedure:

Quote


Public Sub EditCategoriesAndSend()
On Error Resume Next
Dim oItem As MailItem

    Err.Clear
    '**check that we have an inspector window open
    If (ActiveWindow.Class <> ActiveInspector.Class) Then
        Exit Sub
    End If
   
    '**get the item we're viewing
    Set oItem = ActiveInspector.CurrentItem
   
    If (oItem Is Nothing) Then
        Exit Sub
    End If

    oItem.ShowCategoriesDialog
    oItem.Send
   
End Sub

PRICET

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #22 on: June 19, 2009, 03:21:19 AM »
Really appreciate it - works great .

Thanks again

PRICET

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 8
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #23 on: June 19, 2009, 03:57:08 AM »
Hi ....... is there anyway to invoke the spell checker in this procedure. At the moment it brings up the catergories dialogue and then ok "ok" it sends ... but skips the spell checker

Thanks

r0bertdenir0

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 49
    • View Profile
    • Donate to Member
Re: IDEA - AHK script - Outlook'03 Apply Category Label
« Reply #24 on: June 19, 2009, 06:48:52 AM »
Well you can try to change the lines

Quote
    oItem.ShowCategoriesDialog
    oItem.Send
to
Quote
    SendKeys "{F7}", True
    oItem.ShowCategoriesDialog
    oItem.Send

But it will invoke the spellchecker & move on regardless of whether you cancel the spell check.
Outlook doesn't expose a full interface to the spell checker & trying 2 hack it is not worth the effort 4 sumthing like this.
So I suggest use this method & if it becomes a problem, get into the habit of pressing F7 to run spell check yrself, b4 hitting the send button.