Windows 2008 R2中的SMTP事件接收器

我们使用第三方软件发送批量电子邮件。 该软件不提供在BCC中添加电子邮件地址的选项。 但是,根据“合规性规定”,我们有必要在每封发送的电子邮件中添加一个BCC地址。 到目前为止,我们用来将所有的电子邮件从该软件转发到安装了SMTP服务的中间服务器。 我们在该服务器上部署了一个用作SMTP事件接收器的VB6 DLL,并且每次触发SMTP服务的“OnArrival”事件时都会运行它。 DLL将密件抄送地址添加到邮件中。 到现在为止,每件事情都运行良好。 现在,我们必须将这些服务器升级到Windows Server 2008 R2。 我已经用C#重写了VB6 Event Sink。 代码是这样的:

using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using ADODB; using CDO; using SEOLib; namespace OnArrivalSink { [Guid("8E9B5A44-ADC3-4752-9CF6-C5333A6B17CF")] public class CatchAll : ISMTPOnArrival, IEventIsCacheable { void IEventIsCacheable.IsCacheable() { //This will return S_OK by default } void ISMTPOnArrival.OnArrival(Message msg, ref CdoEventStatus eventStatus) { try { ProcessMessage(msg); } catch (Exception e) { string errorInfo = "ERROR MESSAGE: " + e.Message + "\n" + "INNER EXCEPTION: " + e.InnerException + "\n" + "SOURCE: " + e.Source + "\n" + "STACK TRACE: " + e.StackTrace + "\n"; //Write to Event Log EventLog evtLog = new EventLog(); evtLog.Source = "OnArrivalSink"; evtLog.WriteEntry(errorInfo, EventLogEntryType.Error); } eventStatus = CdoEventStatus.cdoRunNextSink; } private void ProcessMessage(IMessage msg) { //Get the list of recipients that the message will be actually delivered to string recipientList = msg.EnvelopeFields["http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"].Value.ToString(); //Add a recipient in BCC form recipientList = recipientList + "SMTP:[email protected];"; msg.EnvelopeFields["http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"].Value = recipientList; msg.EnvelopeFields.Update(); msg.DataSource.Save(); } } 

}

由上面的代码生成的DLL使用RegAsm.exe注册,它已成功注册。 使用Microsoft提供的VBScript将DLL绑定到SMTP“OnArrival”事件,并且也没有发生任何问题。 但是,DLL根本不工作。 我试着logging每一步,但就好像这个DLL根本不起作用。 它在Windows XP机器中工作正常。 我们对使用Microsoft Exchange Server不感兴趣,因为这对我们来说太过分了。 请帮忙。

MS的一些devise人员有一个好主意,即使SMTP服务不再使用IIS7 +中的“事件接收器”,注册例程应该返回指示成功。

您必须将您的“filter”重新编写为传输事件接收器 。 它是相似的,所以它不应该花太长的时间。