c# - 邮政添加自定义 header

标签 c# asp.net-mvc sendgrid postal

我在我的 C# MVC 应用程序中使用 Postal.NET 发送电子邮件:

http://aboutcode.net/postal/

我正在使用 SendGrid 发送电子邮件。 Sendgrid 需要使用“X-SMTPAPI” header 属性发送自定义 header 参数。

如何在 Postal.NET 中添加自定义 header 值? (例如 myMessage.Headers.Add("X-SMTPAPI", jsonString);

最佳答案

我没有使用过这个库,但在我看来,您只需在电子邮件上方的 View 中添加标题即可。您创建的 View 包含整个电子邮件(包括标题)。在文档中,您可以看到 View 中包含“To:”和“From:”。这是来自文档:

To: @ViewBag.To
From: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="402c2f2c2321343300372522332934256e232f2d" rel="noreferrer noopener nofollow">[email protected]</a>
Subject: Important Message

Hello,
You wanted important web links right?
Check out this: @ViewBag.FunnyLink

<3

所以我认为你可能会这样做:

X-SMTPAPI: @ViewBag.jsonAPIString
To: @ViewBag.To
From: <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ef2f1f2fdffeaeddee9fbfcedf7eafbb0fdf1f3" rel="noreferrer noopener nofollow">[email protected]</a>
Subject: Important Message

Hello,
You wanted important web links right?
Check out this: @ViewBag.FunnyLink

<3

关于c# - 邮政添加自定义 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41084193/

相关文章:

asp.net-mvc - 仅在 IIS 部署后出现 Asp.net Web api 异常 : A route named 'HelpPage_Default' is already in the route collection

asp.net-mvc - 如何处理MVC5中的config和代码中的404错误?

c# - 任何将 Sendgrid 的解析 API 与 c# ASP.NET MVC 一起使用的人

c# - 我的 Visual Studio C# 编译需要多长时间?

c# - 如何检索 Azure blob 的内容?

asp.net-mvc - 在 Controller 的构造函数中访问 HttpContext.Request

python-3.x - 如何发送多个收件人sendgrid V3 api Python

Azure 市场 Sendgrid 用户名

c# - Google Speech API v2 结果为空白

c# - 具有 Multi-Tenancy 数据访问的 Web API 身份验证