DocumentItem open event not working

J

Jonatan

Hi all,

I am developing an addin in c# using Outlook 2003 and Exchange 5.5. I
am trying to do the following.

I have got DocumentItems (not MailItems) in certain folders. I want to
capture the open event on the Document, cancel it and then open a
customized c# form.

I thought I could do that by capturing the FolderSwitchEvent when the
user goes to one of these folders with DocumentItems and then register
the Open event on each document

The first event works. But the second one, the DocumentItem.Open, never
fires.

Any ideas?

You can find my code below

Thank you very much

Jonatan

public void OnStartupComplete(ref System.Array custom)
{
...
applicationObject.ActiveExplorer().FolderSwitch += new
Outlook.ExplorerEvents_10_FolderSwitchEventHandler(Connect_FolderSwitch);
}

private void Connect_FolderSwitch()
{
string folderPath =
applicationObject.ActiveExplorer().CurrentFolder.FullFolderPath;

if (folderPath.IndexOf(Constants.PROCESS_MAIL_FOLDER) >= 0)
{
Outlook.MAPIFolder folder =
applicationObject.ActiveExplorer().CurrentFolder;

foreach(Outlook.DocumentItem documentItem in folder.Items)
{
documentItem.Open += new
Outlook.ItemEvents_10_OpenEventHandler(documentItem_Open);
}
}
}

private void documentItem_Open(ref bool Cancel)
{
MessageBox.Show("Hello");
Cancel = true;
}
 

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