PDA

View Full Version : custom follow-up vba script while creating new mails



spi5839
05-05-2012, 12:09 PM
I'm using OL 2010 and categorize my emails with some few categories to track them.

I'd like to achieve the following:

1) categorized emails don't get archived

2) already categorize new emails while I create them (and not after I sent them)

3) category only visible for me but not the recipient

4) display the chosen category in the new mail window (so I see what I chose)



What I've achieved so far is:

1) not only categorize but also flag the mails as flagged mails don't get archived (hope so...)

2 and 3) unfortunately couldn't find any VBA function to flag an email for me but not the recipient so I'm executing a GUI control (Item.GetInspector.CommandBars.FindControl(, 11634)) to flag the new email while creating it (it's the same like hitting the ribbon button to track an email without due date)

4) if if flag an email I see a notice in the new mail window that the email is flagged - I'd like to add here the email's category but couldn't manage so



I'd highly appreciate if anybody could guide me how to

- flag a new mail for the sender only and set a custom flag name (i.e is there any hidden function to do so?

- display the category in the additional information field in the new mail window above the recipient's address and below the ribbon (this shows up as soon a new mail gets flagged)

- any other idea how to display the chosen category permanently in the new mail window (without creating new forms or something)



I add my function to flag and categorize a new mail. This function expects a category as a parameter, sets the category and flags the message for the sender only (if the category is empty the message gets unflagged again).

Function CategoriesButton(ByVal cat As String)
Dim Item As Outlook.MailItem
Dim objInsp
Dim colCB
Dim objCBB
On Error Resume Next

Set Item = Application.ActiveInspector.CurrentItem
Set objInsp = Item.GetInspector
Set colCB = objInsp.CommandBars

If cat = "" Then
Set objCBB = colCB.FindControl(, 2776)
Else
Set objCBB = colCB.FindControl(, 11634)
End If

If Not objCBB Is Nothing Then
objCBB.Execute
End If

Item.Categories = cat

Set objCBB = Nothing
Set colCB = Nothing
Set objInsp = Nothing

End Function