Outlook programming - Where to start?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posted this on the General Outlook group but got no replies, and think, on reflection, I should have put it here instead. Please forgive the multi-posting then.


I want to automatically open the categories dialog box when I send a message, or when I open one I have received. I expect this is pretty basic programming, but I can't get my head around how to code in Outlook (or even where to do it!).

Please could anyone offer a few simple pointers?
 
The version is *always* important, because the Outlook object model has been enhanced with each subsequent version.

If you're new to Outlook VBA macros, these web pages should help you get started:

http://www.winnetmag.com/Articles/Index.cfm?ArticleID=21522&pg=1
http://www.outlookcode.com/d/vb.htm

The event that fires when you open an item is Inspectors.NewInspector. The code to instantiate the necessary objects and show the categories dialog on only new messages would look like this and should be placed in the ThisOutlookSession module:

Dim WithEvents colInsp As Inspectors

Private Sub Application_Startup()
Set colInsp = Application.Inspectors
End Sub

Private Sub colInsp_NewInspector(ByVal Inspector As Inspector)
Dim objItem As Object
Set objItem = Inspector.CurrentItem
If objItem.Class = olMail Then
If objItem.Size = 0 Then
objItem.ShowCategoriesDialog
End If
End If
Set objItem = Nothing
End Sub

Restart Outlook or run the Application_Startup procedure to get things started. Note that the Categories dialog will appear **before** the new message opens. That's just the way it works; you can't change it.

As for outgoing items, I'd recommend that you monitor the SentItems folder for new items using the MAPIFolder.Items.ItemAdd method. See http://www.outlookcode.com/codedetail.aspx?id=456 for sample code

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Thanks Sue

This will give me something to play with for a little while.

I am very grateful.

Vaughan
 
Back
Top