asp.net 邮件添加 ReplyTo
如何在 ReplayTo
字段中添加与发件人不同的电子邮件地址? 似乎 MailMessage.ReplyTo
已被弃用,因此我尝试使用 ReplyToList
代替。
但它告诉我
Property or indexer 'System.Net.Mail.MailMessage.ReplyToList' cannot be assigned to -- it is read only
这是到目前为止我的代码:
var reply = new MailAddressCollection();
reply.Add("[email protected]");
MailMessage mail = new MailMessage(senderEmail,usr.Email,"subject","message");
mail.ReplyToList = reply;
var smtp = new SmtpClient();
smtp.Send(mail);
How can i add a a different email then the sender in the ReplayTo
field ?
Seems MailMessage.ReplyTo
is deprecated so I'm trying to use ReplyToList
instead.
But it's telling me that
Property or indexer 'System.Net.Mail.MailMessage.ReplyToList' cannot be assigned to -- it is read only
Here is my code so far:
var reply = new MailAddressCollection();
reply.Add("[email protected]");
MailMessage mail = new MailMessage(senderEmail,usr.Email,"subject","message");
mail.ReplyToList = reply;
var smtp = new SmtpClient();
smtp.Send(mail);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法将其设置为全新的
MailAddressCollection
,但您可以直接添加到现有的MailAddressCollection
,如下所示:You can't set it to a whole new
MailAddressCollection
, but you can add directly to the existingMailAddressCollection
, like this:由于
ReplyToList
是只读属性,因此您可以做的唯一方法是:Since the
ReplyToList
is a readonly property,the only way you can do is :