[E2007][TA][C#]Sending a separate message within a transport agent RRS feed

  • Question

  • Regarding Exchange 2007 Transport Agents. I am trying to intercept messages via a transport agent and if they hit a certain criteria to Delete the message and send an NDR message. What I am trying to do is figure out how to set the Body of the NDR. there is a lot of discussion online about the EWS API and outlook but very little information about these namespaces:


    using Microsoft.Exchange.Data.Transport;

    using Microsoft.Exchange.Data.Transport.Email;

    using Microsoft.Exchange.Data.Transport.Routing;

    using Microsoft.Exchange.Data.Mime;




        public class AzRoutingAgent : RoutingAgent



     private static SmtpServer mSmtpServer;


            internal void EventHandler(ResolvedMessageEventSource source, QueuedMessageEventArgs e)


                  if (CRITERIA IS MET)







           internal void SendNdr(MailItem msg) 


                    var ndr = EmailMessage.Create(BodyFormat.Text);

                    ndr.Sender = new EmailRecipient("Mailer Demon", "");

                    ndr.To.Add(new EmailRecipient(msg.Message.Sender.DisplayName, msg.Message.Sender.SmtpAddress));

                    ndr.Subject = "NDR Regarding message: " + msg.Message.Subject;

     //TODO: Need to set the body of the message from a text file (plain text)





    Thanks in advance

    • Edited by T. Sweet Friday, February 3, 2012 9:31 PM updating title
    Friday, February 3, 2012 9:25 PM