【发布时间】:2019-02-08 09:34:42
【问题描述】:
我有一个 byte[],它是我的 ASP.NET Core 2.1 应用程序中下载的 pdf 文件。
我正在尝试将此作为附件附加到 sendgrid 电子邮件中。
public async Task SendEmail(byte[] Attachment = null)
{
var client = new SendGridClient(apiKey);
var msg = new SendGridMessage();
// I also set the To, Subject, body etc etc
msg.AddAttachment("test.pdf",Convert.ToBase64String(Attachment) ,"application/pdf","inline");
var response = await client.SendEmailAsync(msg);
}
我收到“BadReqest”状态代码。如果我删除 AddAttachment 行,则该消息被接受。
我做错了什么?
【问题讨论】:
标签: c# asp.net asp.net-core sendgrid