Unable to add reply to in mail header C#
c#
Solution
Exception tells you what to do - use ReplyToList:
In your case it looks like this:
MailMessage mail = new MailMessage("\"Company Name\" <info@company.com>", textBox_Email_to.Text);
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "host name";
mail.Subject = "test email";
mail.Body = file; // file contains some text
//mail.Headers.Add("reply-to", "service@company.de");
mail.ReplyToList.Add(new MailAddress("service@company.de", "reply-to"));
mail.IsBodyHtml = true;
client.Send(mail);
Problem
I am developing Windows Form Application, Dot net Framework 4. for sending SMTP emails. I am using following code to send email. ``` MailMessage mail = new MailMessage("\"Company Name\" <info@company.com>", textBox_Email_to.Text); SmtpClient client = new SmtpClient(); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "host name"; mail.Subject = "test email"; mail.Body = file; // file contains some text mail.Headers.Add("reply-to", "service@company.de"); mail.IsBodyHtml = true; client.Send(mail); ``` The only problem is `mail.Headers.Add("reply-to", "service@company.de");` is not working. I also tried to use `mail.ReplyTo = new MailAddress("service@company.de");` But still its not working. While using `mail.ReplyTo` I am getting this warning: 'System.Net.Mail.MailMessage.ReplyTo' is obsolete: '"ReplyTo is obsoleted for this type. Please use ReplyToList instead which can accept multiple addresses.