SendGrid Webhook 事件自定义 Headers

SendGrid Webhook Event Custom Headers

在通过 SendGrid 发送电子邮件时,我正在发送自定义 headers。我有一个 Function App 监听来自 SendGrid 的 Webhook 事件。但是我没有在 WebHook 事件中得到那些自定义 headers 。有没有办法配置 webhooks 以从 SendGrid 返回自定义 headers?

var client = new SendGridClient("API_KEY");
var from = new EmailAddress("test@example.com", "Example User");
var subject = "Testing with SendGrid API";
var to = new EmailAddress("joe@test.com", "Example User");
var plainTextContent = "Test Content";
var htmlContent = "<strong>Testing with HTML content</strong>";
var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var identifiers = new Dictionary<String, String>();
identifiers["application"] = "APP_NAME_GOES_HERE";
identifiers["resource"] = "RESOURCE_NAME_GOES_HERE";    
 msg.AddHeaders(identifiers);   
var response = await client.SendEmailAsync(msg);

此处为 Twilio SendGrid 开发人员布道师。

当您使用 API 发送电子邮件时,在 webhook 中返回属性的最佳方式是使用自定义参数 (custom_args)。

您可以将它们添加到此代码中,方法是将 AddHeaders 替换为 addCustomArgs,如下所示:

var identifiers = new Dictionary<String, String>();
identifiers["application"] = "APP_NAME_GOES_HERE";
identifiers["resource"] = "RESOURCE_NAME_GOES_HERE";    
msg.addCustomArgs(identifiers);
var response = await client.SendEmailAsync(msg);

有关更多信息,请参阅 examples in the tests