在ASP.NET中的SendGrid中的“from”字段中添加名称[duplicate]

问题描述 投票:-1回答:1

这个问题在这里已有答案:

收到邮件后,在“发件人”中,我需要显示代表邮件发送对象的人的姓名。我认为我需要的是this答案的c#版本

提前致谢

c# .net sendgrid
1个回答
2
投票

试试看MailMessage课程。您在该页面上有一个示例。

MailAddress from = new MailAddress("[email protected]", "Ben Miller");
MailAddress to = new MailAddress("[email protected]", "Jane Clayton");
MailMessage message = new MailMessage(from, to);

message.Subject = "Using the SmtpClient class.";
message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
SmtpClient client = new SmtpClient();
client.Send(message);

请注意,没有params的SmtpClient从app.config / web.config获取配置。您可以查看mailSettings section以获取更多配置信息

© www.soinside.com 2019 - 2024. All rights reserved.