我试图编写一个交换传输代理程序,以测试主题​​行是否为空,如果是,它将插入默认主题行。每当我编译,安装并启用此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);
            }
        }
    }

}


有谁知道为什么这可能行不通?

谢谢

最佳答案

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

关于c# - C#Exchange 2007传输代理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4608488/

10-08 21:07