asp.net邮件附加的ReplyTo [英] asp.net mail add ReplyTo

查看:3013
本文介绍了asp.net邮件附加的ReplyTo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何添加一个不同的电子邮件,然后在 ReplayTo 字段发送者?
似乎 MailMessage.ReplyTo 是德precated所以我试图用 ReplyToList 代替。

但它告诉我,

 属性或索引System.Net.Mail.MailMessage.ReplyToList'不能被分配​​到 - 它是只读

下面是我的code迄今:

  VAR回复=新MailAddressCollection();
 reply.Add(test@test.com);
 邮件MAILMESSAGE新= MAILMESSAGE(SENDEREMAIL,usr.Email,主题,消息);
 mail.ReplyToList =回复;
 VAR SMTP =新SmtpClient();
 smtp.Send(邮件);


解决方案

您不能的设置的就到了一个全新 MailAddressCollection ,但您可以直接添加到现有的 MailAddressCollection ,就像这样:

 邮件MAILMESSAGE新= MAILMESSAGE(SENDEREMAIL,usr.Email,主题,消息);
mail.ReplyToList.Add(test@test.com);
VAR SMTP =新SmtpClient();
smtp.Send(邮件);

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("test@test.com");
 MailMessage mail = new MailMessage(senderEmail,usr.Email,"subject","message");
 mail.ReplyToList = reply;
 var smtp = new SmtpClient();
 smtp.Send(mail);

解决方案

You can't set it to a whole new MailAddressCollection, but you can add directly to the existing MailAddressCollection, like this:

MailMessage mail = new MailMessage(senderEmail,usr.Email,"subject","message");
mail.ReplyToList.Add("test@test.com");
var smtp = new SmtpClient();
smtp.Send(mail);

这篇关于asp.net邮件附加的ReplyTo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆