Reputation: 11
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?
Upvotes: 1
Views: 598
Reputation: 2552
Most scenarios only use MailItem.Message
, and don't need any other properties of the MailItem
itself. Since EmailMessage
can be created easily, maybe you can use just that for testing.
Your real event handler could just call a method specifying MailItem.Message
, and for testing you could call this same method with your constructed test message.
Upvotes: 0
Reputation: 86
Not sure y u want to create a mailiitem object for testing.pls tell the purpose of developing the agent so that we can help u better.mailitem object represents the email that is sent and u will be able to get most of the details of the email from the mailitem object depending on the event at which u target on debugging the agent.
Upvotes: 0