【问题标题】:Adding a name to the “from” field in SendGrid in ASP.NET [duplicate]在 ASP.NET 的 SendGrid 中向“发件人”字段添加名称 [重复]
【发布时间】:2019-02-14 18:56:14
【问题描述】:

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

提前致谢

【问题讨论】:

    标签: c# .net sendgrid


    【解决方案1】:

    尝试查看MailMessage 类。您在该页面上有一个示例。

    MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
    MailAddress to = new MailAddress("jane@contoso.com", "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);
    

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

    【讨论】:

    • 这假设 OP 使用的是 SmtpClient 而不是 SendGrid SDK。
    • 如果只是SmtpClient,这是重复的……
    • 我会改为链接到docs.microsoft.com/en-us/dotnet/api/…。关于这个主题更详细。
    猜你喜欢
    • 2013-05-21
    • 1970-01-01
    • 2016-09-27
    • 2017-11-07
    • 2017-10-19
    • 1970-01-01
    • 1970-01-01
    • 2023-01-11
    • 2020-12-15
    相关资源
    最近更新 更多