1

In our Exchange RoutingAgent, we would like to be able to bounce an email back to the sender in the event of an unexpected exception. We would also like to be able to send the bounce message to some pre-defined admin email too if possible. Is there any way to bounce a message in the OnSubmittedMessage or the OnResolvedMessage events? I am hoping there is some method in the Exchange libraries to easily achieve this, or is there some way to create a new MailItem and send it to the original sender and possibly an admin?

1 Answer 1

0

You need to generate a new message to do that there is a sample for this on https://blogs.msdn.microsoft.com/mstehle/2010/03/10/howto-return-to-sender-transport-agent-sample/

You should also be able to use https://msdn.microsoft.com/en-us/library/jj976002(v=exchg.150).aspx

Cheers Glen

2
  • Do you know the best way to determine if I'm processing is a DSN/bounce back message, I need to be able to avoid an infinite loop? I see the Message.MapiMessageClass property, which has a value of "Report.IPM.Note.NDR" but I'm not really certain if this is reliable. Commented May 3, 2016 at 14:28
  • I always add a custom header into any message processed or created this both prevents a loops but it also prevents you processing the item multiple time when it pass though different hub servers. Otherwise you can parse through the Mime Headers to determine the type. Commented May 4, 2016 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.