I have a .NET application that polls an Exchange email mailbox for new messages on a scheduled basis. Further processing happens when new messages are found in the email mailbox. I've encountered an issue with the processing when auto reply messages are received in the mailbox [e.g. auto reply rule, or Out of Office messages].
I need a C# solution to determine if an Exchange mail item is an auto reply message. Is there an attribute on the mail item that indicates if the message is an auto response message?
After struggling with this problem for a while I decided to just use the simplest approach possible.
By using the Exchange web service (exchange.asmx) that is available to Exchange 2007 I decided to just check the subject line of each mail item to see if it contained "Out of Office" before continuing through the processing logic. All of the messages that I was dealing with were auto-reply messages that contained the "Out of Office" subject line.
I'm sure that I'll come across additional use cases of auto-reply messages that do not have "Out of Office" that I'll have to account for in the future. At that time I'll either modify the code to check the subject line against an array of possible subject lines, or continue searching for some additional attribute on the mail item that indicates an auto reply message.
I'm pretty sure that additional attribue is the "Return-Path:" value in the header of the mail item, but I haven't found an easy way to get that attribute. From what I can tell, if the "Return-Path" has a "<>" value, it is an auto reply message otherwise it would have a valid email address.