Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Exchange 2010 Agent not catch

$
0
0

Hi,

I'm creating an agent transport handler for exchange 2010

Below is my code:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Exchange.Data.Transport.Smtp;
using Microsoft.Exchange.Data.Transport;
using Microsoft.Exchange.Data.Transport.Delivery;
using System.IO;
using System.Diagnostics;

namespace ExchangeInAddin
{
    #region InMail
    public class PartialCatchAllFactory : SmtpReceiveAgentFactory
    {
        // Methods
        public override SmtpReceiveAgent CreateAgent(SmtpServer server)
        {
            return new PartialCatchAll();
        }
    }


    public class PartialCatchAll : SmtpReceiveAgent
    {
        // Methods
        public PartialCatchAll()
        {
            this.OnEndOfData += new EndOfDataEventHandler(MyEndOfDataHandler);
            this.OnRcptCommand += new RcptCommandEventHandler(PartialCatchAll_OnRcptCommand);
            this.OnEndOfHeaders += new EndOfHeadersEventHandler(PartialCatchAll_OnEndOfHeaders);

        }
        private void PartialCatchAll_OnEndOfHeaders(ReceiveMessageEventSource source, EndOfHeadersEventArgs e)
        {
            e.MailItem.Message.Subject += "sondh";
        }
        private void PartialCatchAll_OnRcptCommand(ReceiveCommandEventSource source, RcptCommandEventArgs e)
        {
            e.MailItem.Message.Subject += "hello OnRcpt here";
        }
        private void MyEndOfDataHandler(ReceiveMessageEventSource source, EndOfDataEventArgs e)
        {
            e.MailItem.Message.Subject += " - this text appended by MyAgent";

}

    }

}

This is installation command

Install-TransportAgent -Name "ExchangeInAddin" -AssemblyPath "C:\ExchangeDemo\ExchangeInAddin.dll" -TransportAgentFactory "ExchangeInAddin.PartialCatchAllFactory"

Enable-TransportAgent -Name "ExchangeInAddin"

Restart-Service MSExchangeTransport

IISRESET

I check agent by Get-TransportAgent. The state of my agent is enable.

I built and installed success. But when I sent email to test. The subject was not affected by events that I have catched.

What's problem with my agent transport ?

Waiting for the help from everyone !


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>