Responding to Delete and move events in outlook.

K

Keith Giddings

Sorry for cross posting this, but I can't figure out which of the three
groups is most relevant.

I need to create a list of items (emails, calendar events, address book
entries etc) whenever one of these items is moved, changed or deleted. The
list is just a simple text file, with each item being named in a similar
way to the way it is named in windows desktop search. Firstly is this
possible by writing some kind of add-in (com is preferred), and secondly
can anyone give me some pointers on how to go about it?

Regards
Keith.
 
E

Eric Legault [MVP - Outlook]

Actually, neither of those groups you posted to is relevant -
microsoft.public.outlook.program_vba is the best.

You need to set a reference to an Items collection object for every folder
containing items you need to monitor for changes. Here's a sample from the
VBA help file:

Dim myOlApp As New Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
Set myOlItems =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub myOlItems_ItemChange(ByVal Item As Object)
Dim prompt As String
If VBA.Format(Item.Start, "h") >= "17" And Item.Sensitivity <> olPrivate
Then
prompt = "Appointment occurs after hours. Mark it private?"
If MsgBox(prompt, vbYesNo + vbQuestion) = vbYes Then
Item.Sensitivity = olPrivate
Item.Display
End If
End If
End Sub

For general info on COM Add-Ins to get you started, see this:

Developing COM Add-ins for Microsoft Outlook:
http://www.outlookcode.com/article.aspx?id=36
 
K

Keith Giddings

Thanks for your help.

Regards
Keith.

Eric Legault said:
Actually, neither of those groups you posted to is relevant -
microsoft.public.outlook.program_vba is the best.

You need to set a reference to an Items collection object for every folder
containing items you need to monitor for changes. Here's a sample from
the
VBA help file:

Dim myOlApp As New Outlook.Application
Public WithEvents myOlItems As Outlook.Items

Public Sub Initialize_handler()
Set myOlItems =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub myOlItems_ItemChange(ByVal Item As Object)
Dim prompt As String
If VBA.Format(Item.Start, "h") >= "17" And Item.Sensitivity <>
olPrivate
Then
prompt = "Appointment occurs after hours. Mark it private?"
If MsgBox(prompt, vbYesNo + vbQuestion) = vbYes Then
Item.Sensitivity = olPrivate
Item.Display
End If
End If
End Sub

For general info on COM Add-Ins to get you started, see this:

Developing COM Add-ins for Microsoft Outlook:
http://www.outlookcode.com/article.aspx?id=36

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top