Search code examples
c#outlookoutlook-addinoutlook-redemption

C# Redemption wrapper class not firing events


I've written the following wrapper class for an Outlook Add-in using Redemption:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace PSTAttachRemove_Redemption
{
    class PSTWatch
    {
        private Redemption.RDOPstStore pst;

        public PSTWatch(Redemption.RDOPstStore rPST)
        {
            pst = rPST;
            pst.OnMessageMoved += new Redemption.IRDOStoreEvents_OnMessageMovedEventHandler(pst_OnMessageMoved);
        }

        void pst_OnMessageMoved(string EntryID)
        {
            Debug.Print(EntryID);
        }
    }
}

In my main add-in code, I am calling this wrapper using this code:

void FileStorePopulation(Redemption.RDOStore store)
{
    switch (store.StoreKind)
    {
        case TxStoreKind.skPstAnsi:
        case TxStoreKind.skPstUnicode:
            PSTWatch p = new PSTWatch(store as RDOPstStore);
            watchedPSTs.Add(store.EntryID, p);
            break;
    }
}

where watchedPSTs is a global variable.

I can see watchedPSTs being populated, but the items never fire when moving a message into a PST. Ideas?

Thanks


Solution

  • How do you initialize RDOSession? Do you call Logon or set RDOSession.MAPIOBJECT to Namespace.MAPIOBJECT from OOM? is watchedPSTs list declared on the global (class) level? Do you use multiple threads?