2

我正在尝试编写一个交换传输代理来测试主题行是否为空,如果是则插入默认主题行。每当我编译、安装和启用此 dll 时,服务器将不再路由电子邮件...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.Exchange.Data.Transport;
using Microsoft.Exchange.Data.Transport.Email;
using Microsoft.Exchange.Data.Transport.Smtp;
using Microsoft.Exchange.Data.Transport.Routing;
using Microsoft.Exchange.Data.Common;

namespace ExchangeTransportAgent
{
    public class RoutingFactory : RoutingAgentFactory
    {

        public override RoutingAgent CreateAgent(SmtpServer server)
        {
            RoutingAgent myAgent = new sRoutingAgent();
            return myAgent;
        }
    }
}




class sRoutingAgent : RoutingAgent
{

    public sRoutingAgent()
    {
        //subscribe to different events
        base.OnSubmittedMessage += new SubmittedMessageEventHandler(SRoutingAgent_OnSubmittedMessage);
    }

    void SRoutingAgent_OnSubmittedMessage(SubmittedMessageEventSource source, QueuedMessageEventArgs e)
    {
        if (e.MailItem.Message.Subject == string.Empty)
        {
            try
            {
                e.MailItem.Message.Subject = "Kranichs Jewelers";


                EventLog.WriteEntry("MY Exchange Routing Agent", "MY ROUTING AGENT CHANGED THE SUBJECT",
                EventLogEntryType.Information, 1337);
            }
            catch (Exception except)
            {
                EventLog.WriteEntry("MY Exchange Routing Agent", except.Message,
                    EventLogEntryType.Error);
            }
        }
    }

}

有谁知道为什么这可能不起作用?

谢谢

4

1 回答 1

2

“EventLog.WriteEntry”可能会引发错误。我遇到了同样的问题,当删除“EventLog.WriteEntry”时一切正常。现在我不知道为什么。

于 2011-03-21T07:56:41.970 回答