gpt4 book ai didi

c# - 在 asp.net 中发送具有特定名称而不是发件人电子邮件的电子邮件

转载 作者:IT王子 更新时间:2023-10-29 04:23:08 25 4
gpt4 key购买 nike

我需要在 asp.net 中发送电子邮件,但我需要发件人显示为“MySiteName”而没有 info@example.com

最佳答案

像这样:

using(MailMessage message = new MailMessage(
new MailAddress("You@Domain.example", "Your Name"),
new MailAddress("Recipient@OtherDomain.example", "Their Name")
)) {
message.Subject = ...;
message.Body = ...;

new SmtpClient().Send(message);
}

您需要在 Web.config 中输入 SmtpClient 的连接设置

关于c# - 在 asp.net 中发送具有特定名称而不是发件人电子邮件的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2737699/

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