Created
June 19, 2020 09:37
-
-
Save tliff/87b43916b08c740881b6fe7c18c3bc02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using Microsoft.Exchange.Data.Transport; | |
using Microsoft.Exchange.Data; | |
using Microsoft.Exchange.Data.Transport.Smtp; | |
namespace MyAgents | |
{ | |
public sealed class MyAgentFactory : SmtpReceiveAgentFactory | |
{ | |
public override SmtpReceiveAgent CreateAgent(SmtpServer server) | |
{ | |
return new MyAgent(); | |
} | |
} | |
public class MyAgent : SmtpReceiveAgent | |
{ | |
public MyAgent() | |
{ | |
this.OnEndOfData += new EndOfDataEventHandler(MyEndOfDataHandler); | |
} | |
private void MyEndOfDataHandler(ReceiveMessageEventSource source, EndOfDataEventArgs e) | |
{ | |
foreach ( EnvelopeRecipient address in e.MailItem.Recipients ) { | |
e.MailItem.Message.RootPart.AppendChild(new Microsoft.Exchange.Data.Mime.TextHeader("X-Original-Destination", address.ToString())); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment