The Three UC Amigos

Three Microsoft UC technology specialists covering U.S. Education

How can I route out certain outbound domains to specific SMTP gateways?

How can I route out certain outbound domains to specific SMTP gateways?

  • Comments 2
  • Likes

I had a Rocky Mountain university ask how they could route specific internally defined SMTP domains that are sending out of the Hub Transport to an Encryption server. To accomplish this, a custom Transport Agent is required.  A transport agent is akin to the event sinks of Exchange 2003 where you have a custom .dll utilized. To read about what one is go here and how to write one go here.

 

I found a sample transport agent that provides similar functionality:

 

namespace FFRouting1
{
    public class SampleRoutingAgentFactory : RoutingAgentFactory
    {
        public override RoutingAgent CreateAgent(SmtpServer server)
        {
            RoutingAgent myAgent = new SRoutingAgent();
            return myAgent;
        }
    }
}

public class SRoutingAgent : RoutingAgent
{
    public SRoutingAgent()
    {
        //subscribe to different events
        base.OnResolvedMessage += new ResolvedMessageEventHandler(SRoutingAgent_OnResolvedMessage);
    }

    void SRoutingAgent_OnResolvedMessage(ResolvedMessageEventSource source, QueuedMessageEventArgs e)
    {
        try 
            {
                RoutingDomain myRoutingOverride = new RoutingDomain("contoso.com");
                foreach (EnvelopeRecipient recp in e.MailItem.Recipients)
                {
                    recp.SetRoutingOverride(myRoutingOverride);

                }

                EventLog.WriteEntry("FFRouting1 Agent", "My Routing Agent fired successfully",
                EventLogEntryType.Information, 555);
            }   

        catch (Exception except)
            {
                EventLog.WriteEntry("FFRouting1 Agent", except.Message,
                EventLogEntryType.Error);
            }
     }

}
Comments
  • I had a Rocky Mountain university ask how they could route specific internally defined SMTP domains that

  • Microsoft Outlook: 9 Things You Didn't Know You Could Do Exchange 2003 servers with build numbers

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment