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:john.doe@xyz.com;"; msg.EnvelopeFields["http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"].Value = recipientList; msg.EnvelopeFields.Update(); msg.DataSource.Save(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)