jlego 15 Posting Pro

I am creating a Transport Agent that tests the subject line of outgoing email from our exchange server (2007). If it is blank (and later I would like to check if it is all uppercase)

i copied the Microsoft.Exchange.Data.Transport.dll and Microsoft.Exchange.Data.Common.dll from the exchange server, and referenced them into a new c# class library.


the code i have is as follows:

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.Length == 0)
        {
            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);
            }
        }
    }

}

im a newbie with transport agents so sorry if this is completely wrong

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.