I am developing a Windows Form application, Dot net Framework 4. for sending SMTP emails.
I use the 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: mail.Headers.Add("reply-to", "service@company.de"); does not work.
I also tried using mail.ReplyTo = new MailAddress("service@company.de");
But still it doesn't work. When using mail.ReplyTo I get this warning:
'System.Net.Mail.MailMessage.ReplyTo' is deprecated: "ReplyTo is deprecated for this type. Instead, use a ReplyToList that can accept multiple addresses.
c #
Kamran
source share