Exchange Server 2007 and 2010. You find a short description on
at ptecs dot de - and you get an eval version from us.
Post by Graham HoskingSender Based Routing is possible either via a Custom Transport Agent or 3rd party tools/appliance. Local authorities needed to comply with strict mail routing rules for COCO and Government Connect policies.
I hope this helps people for the furture both with Exchange 2007 and 2010.
For this example we wanted to routing mail down diffent smart hosts, based on internal senders email address. But not to route internal mail differently. All you need to do is complie the code below in VS2010.
This routing agent was created to resolve the limitation of being able to route different users down the GovConnect send connector, with Sender Based Routing not being available "out of the box? in both Exchange versions 2007 and 2010.
Let's assume that you have an Exchange server with two send connectors, one being named the "Internet Connector" using DNS for the address space *. This connector will deal with all messages leaving the organisation. The other connector will also be an internet connector but named differently, for the example: "SmartHost Connector? this will have settings for the GovConnect smart host you want to use, however the domain name space is set to only allow this domain: "nexthopdomain.com?
? Create an additional send connector "Smarthost Connector" pointing to the smarthost
? Specify a non-existing domain (e.g. nexthopdomain.com) as address space of the new connector
The agent code of this article shows you how to route messages from the domain of "yourdomainnamehere.gcsx.gov.uk? over the new connector, the routing for all other sender's won't be changed.
Make sure you change this part of the code to suit your domain and any other customisations. ;-) - e.g "youdomainnamehere!!!"
This code is released on a "as is? basis and has no liability to the Originator for use or any security implications that is may have.
1.) Create a C# project (dll/library type)
a. Microsoft.Exchange.Data.Common.dll
b. Microsoft.Exchange.Data.Transport.dll
3.) Add references to the two DLLs to the C# project using the Visual Studio solution explorer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
//This is a custom transport agent for GovConnect re-routing, created by. 01/08/10 GH
namespace RoutingAgentOverride
{
public class gcRoutingAgentFactory : RoutingAgentFactory
{
public override RoutingAgent CreateAgent(SmtpServer server)
{
RoutingAgent myAgent = new ownRoutingAgent();
return myAgent;
}
}
}
public class ownRoutingAgent : RoutingAgent
{
public ownRoutingAgent()
{
//subscribe to different events
base.OnResolvedMessage += new ResolvedMessageEventHandler(ownRoutingAgent_OnResolvedMessage);
}
void ownRoutingAgent_OnResolvedMessage(ResolvedMessageEventSource source, QueuedMessageEventArgs e)
{
try
{
//
// This next bit checked each mail item for the secure domain for GCSX and subdomain
//
//
if (e.MailItem.FromAddress.DomainPart.Contains("domainnamehere.gcsx.gov.uk"))
{
// Here we set the address space we want to use for the next hop. Note that this doesn't change the recipient address.
// Setting the routing domain to "nexthopdomain.com" only means that the routing engine chooses a suitable connector
// for nexthopdomain.com instead of using the recipient's domain.
RoutingDomain myRoutingOverride = new RoutingDomain("nexthopdomain.com");
foreach (EnvelopeRecipient recp in e.MailItem.Recipients)
{
if (!recp.Address.DomainPart.Contains("YOUR-INTERNAL-DOMAINNAME_HERE"))
{
recp.SetRoutingOverride(myRoutingOverride);
}
}
}
}
catch // (Exception except)
{
}
}
}
5.) Compile the DLL
6.) Copy the DLL to the HubTransport server
Install-TransportAgent "GCagent" -TransportAgentFactory "RoutingAgentOverride.gcRoutingAgentFactory" -AssemblyPath "Path to DLL"
Enable-TransportAgent "GCSX Agent"
9.) IMPORTANT: Exit Powershell
10.) IMPORTANT: Restart the MSExchangeTransport service, (restart-service msexchangetransport)
11.) Verify that the agent was successfully enabled / registered by running Get-Transportagent
Post by Graham HoskingSender Based Routing is possible either via a Custom Transport Agent or 3rd party tools/appliance. Local authorities needed to comply with strict mail routing rules for COCO and Government Connect policies.
I hope this helps people for the furture both with Exchange 2007 and 2010.
For this example we wanted to routing mail down diffent smart hosts, based on internal senders email address. But not to route internal mail differently. All you need to do is complie the code below in VS2010.
This routing agent was created to resolve the limitation of being able to route different users down the GovConnect send connector, with Sender Based Routing not being available "out of the box? in both Exchange versions 2007 and 2010.
Let's assume that you have an Exchange server with two send connectors, one being named the "Internet Connector" using DNS for the address space *. This connector will deal with all messages leaving the organisation. The other connector will also be an internet connector but named differently, for the example: "SmartHost Connector? this will have settings for the GovConnect smart host you want to use, however the domain name space is set to only allow this domain: "nexthopdomain.com?
? Create an additional send connector "Smarthost Connector" pointing to the smarthost
? Specify a non-existing domain (e.g. nexthopdomain.com) as address space of the new connector
The agent code of this article shows you how to route messages from the domain of "yourdomainnamehere.gcsx.gov.uk? over the new connector, the routing for all other sender's won't be changed.
Make sure you change this part of the code to suit your domain and any other customisations. ;-) - e.g "youdomainnamehere!!!"
This code is released on a "as is? basis and has no liability to the Originator for use or any security implications that is may have.
1.) Create a C# project (dll/library type)
a. Microsoft.Exchange.Data.Common.dll
b. Microsoft.Exchange.Data.Transport.dll
3.) Add references to the two DLLs to the C# project using the Visual Studio solution explorer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
//This is a custom transport agent for GovConnect re-routing, created by. 01/08/10 GH
namespace RoutingAgentOverride
{
public class gcRoutingAgentFactory : RoutingAgentFactory
{
public override RoutingAgent CreateAgent(SmtpServer server)
{
RoutingAgent myAgent = new ownRoutingAgent();
return myAgent;
}
}
}
public class ownRoutingAgent : RoutingAgent
{
public ownRoutingAgent()
{
//subscribe to different events
base.OnResolvedMessage += new ResolvedMessageEventHandler(ownRoutingAgent_OnResolvedMessage);
}
void ownRoutingAgent_OnResolvedMessage(ResolvedMessageEventSource source, QueuedMessageEventArgs e)
{
try
{
//
// This next bit checked each mail item for the secure domain for GCSX and subdomain
//
//
if (e.MailItem.FromAddress.DomainPart.Contains("domainnamehere.gcsx.gov.uk"))
{
// Here we set the address space we want to use for the next hop. Note that this doesn't change the recipient address.
// Setting the routing domain to "nexthopdomain.com" only means that the routing engine chooses a suitable connector
// for nexthopdomain.com instead of using the recipient's domain.
RoutingDomain myRoutingOverride = new RoutingDomain("nexthopdomain.com");
foreach (EnvelopeRecipient recp in e.MailItem.Recipients)
{
if (!recp.Address.DomainPart.Contains("YOUR-INTERNAL-DOMAINNAME_HERE"))
{
recp.SetRoutingOverride(myRoutingOverride);
}
}
}
}
catch // (Exception except)
{
}
}
}
5.) Compile the DLL
6.) Copy the DLL to the HubTransport server
Install-TransportAgent "GCagent" -TransportAgentFactory "RoutingAgentOverride.gcRoutingAgentFactory" -AssemblyPath "Path to DLL"
Enable-TransportAgent "GCSX Agent"
9.) IMPORTANT: Exit Powershell
10.) IMPORTANT: Restart the MSExchangeTransport service, (restart-service msexchangetransport)
11.) Verify that the agent was successfully enabled / registered by running Get-Transportagent
Submitted via EggHeadCafe
WCF Generic DataContract object Serializer
http://www.eggheadcafe.com/tutorials/aspnet/59ae2b9e-a3be-4cd5-a0ef-939a7abbdc3a/wcf-generic-datacontract-object-serializer.aspx