gpt4 book ai didi

asp.net 邮件添加 ReplyTo

转载 作者:行者123 更新时间:2023-12-02 15:34:36 25 4
gpt4 key购买 nike

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

最佳答案

您无法将其设置为全新的MailAddressCollection,但您可以直接添加到现有的MailAddressCollection,如下所示:

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,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3667006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com