我正在发送带有asp.net c#的电子邮件。除了回复,一切都很完美。我正在设置回复并将电子邮件发送给自己。在电子邮件客户端(即.gmail)中,回复是正确的,但回复发送给电子邮件发件人而不是我已分配的备用回复。这是我的代码:
public void SendEmail(string subject, string body, string to, string reply,string replytoname, int nameID)
{
MailAddress Sender = new MailAddress("sender@mydomain.com", "sender name", System.Text.Encoding.UTF8);
MailAddress Receiver = new MailAddress(to);
MailAddress Reply = new MailAddress(reply, replytoname, System.Text.Encoding.UTF8);
MailMessage msg = new MailMessage(Sender, Receiver);
msg.Subject = subject;
msg.SubjectEncoding = System.Text.Encoding.UTF8;
msg.BodyEncoding = System.Text.Encoding.UTF8;
msg.IsBodyHtml = true;
msg.ReplyTo = Reply;
msg.Body = body;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.mydomain.com";
smtp.Port = 25;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("sender@mydomain.com", "password");
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
smtp.Send(msg);
}