Hey, I am writing an Outlook 2007 addin. All I am doing is:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Outlook.Folder root;
//creates Spam folder if it dosen't exist
if (!SpamFolderExist())
{
CreateSpamFolder();
}
root = (Outlook.Folder)this.Application.Session.DefaultStore.GetRootFolder();
//set BeforeItemMove event for spam and inbox folders
spamFolder = (Outlook.Folder)root.Folders["Spam"];
inboxFolder = (Outlook.Folder)this.Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
spamFolder.BeforeItemMove += new Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(BeforeItemMoveFromSpam);
inboxFolder.BeforeItemMove += new Microsoft.Office.Interop.Outlook.MAPIFolderEvents_12_BeforeItemMoveEventHandler(BeforeItemMoveFromInbox);
//set new mail event
this.Application.NewMail += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_NewMailEventHandler(OnNewMail);
}
And the problem is that, even if I am writing nothing in BeforeItemMoveFromInbox and BeforeItemMoveFromSpam methods, the application has a strange behavior. After I am moving some mails, it just not performs any more move action for a particular mail. It seems that a mail is blocked and I just can’t move it. After performing other moving actions other mails are blocked and the one that was previously blocked can be moved. The idea is that after a mail is blocked it will always be at least one mail that cannot be moved. In other words randomly some of moving actions fail. I have to say that I am not doing anything else than moving mails from a folder to another and that I get no error message. I also tried to set the cancel parameter of BeforeItemMove event handlers to false just at the end of the methods but I got the same behavior.