2
我試圖編寫一個交換傳輸代理,測試以查看主題行是否爲空,如果它是插入默認主題行。每當我編譯,安裝和啓用該DLL的服務器將不再將電子郵件路由......C#Exchange 2007傳輸代理
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);
}
}
}
}
沒有人知道爲什麼這可能無法正常工作?
謝謝
安裝-TransportAgent -Name 「DefaultSubjectAgent」 -TransportAgentFactory 「ExchangeTransportAgent.RoutingFactory」 -AssemblyPath 「E:\ TransportAgents \ ExchangeTransportAgent.dll」 啓用-TransportAgent -Identity 「DefaultSubjectAgent」 – Jeff 2011-01-05 20:00:18
這些都是我運行的命令安裝並啓用代理 – Jeff 2011-01-05 20:00:50