简体   繁体   中英

C# CDO for Eventsink

I have a class a1 which is implementing ISMTPOnArrival.

In my public method

public void OnArrival(Message Msg, ref CdoEventStatus EventStatus)
{
    string strFixedList = Msg.EnvelopeFields["http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"].Value.ToString();

}

I am writing an Nunit Test for this event sink. In my unit test method i have a private method which would pick up and eml file and returns me an CDO.Message and this object is passed to onArrival.

private CDO.Message ReadMessage(String emlFileName)
{
    CDO.Message msg = new CDO.MessageClass();
    ADODB.Stream stream = new ADODB.StreamClass();
    ...
    msg.DataSource.OpenObject(stream, "_Stream");
    msg.DataSource.Save();
    return msg;
}

when i call the public method

a1 b = new a1();

b.OnArrival(msg, ref cdoevent);

An exception is thrown in "Msg.EnvelopeFields[" http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist "]". Can some one please let me know what is the issue?.

The exception is "The requested property or feature, while supported, is not available at this time or in this context".

There is a work around and had a flag which was set up and if it is a unit test then i would hardcode a envelope fields.

This was working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM