Search code examples
c#emailsmtpexchange-server

Out of office replies are sent to 'from' address, 'not reply-to'


I am sending emails to clients in three different locations, using a common email address. Any errors/ out of office replies should go to local offices for them to deal with. So I use:

from: [email protected] reply-to: [email protected]

from: [email protected] reply-to: [email protected]

from: [email protected] reply-to: [email protected]

This seems to work well for email fails (wrong adddress, etc.) but Out of Office replies from Exchange always go to the sender address, [email protected]. I need them to go to the local office, reply-to address.

Any idea how I can solve this? I am sending the email from c#, using the standard MailMessage:

MailMessage mail = new 
mail.Subject = mailDetail["subject"].ToString();
mail.Body = mailDetail["body"].ToString();

// From 
mail.From = new MailAddress(ConfigManager.GetSetting("MailSender"));

// Reply to (boucebacks / out of office etc)
mail.ReplyTo = new MailAddress(mailDetail["reply_to"].ToString());
mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

Thanks for any help,

Ryan


Solution

  • It's up to anyone/thing that responds to the mail to choose which property is most appropriate to use. The reply-to property should of course be used if it's a real reply, but an error message might not be seen as a reply, so the from property may be used for that in some cases. As you see, you will get different results depending on who/what is answering, and why.

    You can use the Sender property to specify the actual sender as an addition to the from property. If it's handled properly, that is where the error messages should go if the reply-to property isn't used.