I've been writing an Exchange Transport Agent, and I seem to have everything figured out in terms of actually developing it. But now it's time for testing, and I've hit a problem.
I'm listening for the OnEndOfData event so that I can peek at the entire email. The email arrives wrapped in a EndOfDataEventArgs object, which contains a MailItem object. It is this MailItem object which contains the email, and is causing the problem. I want to construct a MailItem object so I can test that everything operates as expected when an email is received. But as of yet, I've been unable to do so.
Note that this is a Microsoft.Exchange.Data.Transport.MailItem object, not Microsoft.Office.Interop.Outlook.MailItem. Thus, using Application.CreateItem() will not work.
MailItem is abstract, so I tried subclassing it. But upon compilation, it came to light that MailItem contains a number of abstract internal properties and/or methods. Thus, since I must override them, but I cannot do so due to an inability to see them, this approach doesn't work.
Is there some factory method somewhere that I'm missing? Is there some built-in class that extends MailItem that I've overlooked? Or is there simply no way of creating a MailItem from outside the Exchange Transport Agent DLLs?