If you need the Categories dialog to automatically appear when the user
clicks the Send button, you need to do something like this:
Private Sub objMailItem_Send(Cancel As Boolean)
If objMailItem.Categories = "" Then
'Prompt for Categories
objMailItem.ShowCategoriesDialog
objMailItem.Save
End If
End Sub
To do this though, you have to set a reference to the Inspectors collection
when Outlook starts, and every time a new e-mail is created you need to get a
handle to the Inspector and MailItem object. I've got an article on my blog
that explains how to do this:
Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/articles/2224.aspx
It's usually best to design this as a COM Add-In rather than macros in your
VBA Project, because they are easier to distribute and install for multiple
users. This link has good info on COM Add-Ins:
Developing COM Add-ins for Microsoft Outlook:
http://www.outlookcode.com/d/comaddins.htm
As for choosing the e-mail account to send the message with, there is no
point checking to see if an account hasn't been chosen because the default
account is always used if no other account is selected. The only way to
programmatically set the sending account is to get a reference to the menu
item and call it's Execute method (however, you need to know the name or
ordinal position of the account name in the menu):
Sub ChangeSendingAccount()
Dim objCBPU As Office.CommandBarPopup
Dim objCBB As Office.CommandBarButton
Set objCBPU = ActiveInspector.CommandBars.FindControl(, 31224) 'get
Accounts button on Standard toolbar
'Get menu item by name or index number
Set objCBB = objCBPU.Controls.Item("&1 Microsoft Exchange Server")
'Set objCBB = objCBPU.Controls.Item(2)
objCBB.Execute
Set objCBPU = Nothing
Set objCBB = Nothing
End Sub