我在我的 C# MVC 应用程序中使用 Postal.NET 发送电子邮件:
我正在使用 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/