我正在使用官方的 C# Mailjet SDK ( https://github.com/mailjet/mailjet-apiv3-dotnet )。到目前为止工作正常。
但是如何添加附件?
我懂了
Mailjet.Client.Resources
有 InlineAttachments 和 Attachments,但我该如何使用呢?
这是到目前为止的代码片段:
MailjetRequest request = new MailjetRequest { Resource = Send.Resource }
.Property(Send.FromEmail, emailOperatable.FromEmailaddress)
.Property(Send.FromName, emailOperatable.FromName)
.Property(Send.Subject, emailOperatable.Subject)
.Property(Send.TextPart, emailOperatable.TextBody)
.Property(Send.HtmlPart, emailOperatable.HtmlBody)
.Property(Send.Recipients, new JArray { new JObject { { "Email", emailOperatable.ContactEmailaddress }, { "Name", emailOperatable.CreateSendToName() } } });
试过了。喜欢
request.Property(Send.Attachments, "path/to/file.zip");
但这不起作用。
更新
像这样工作:
.Property(Send.Attachments, new JArray { new JObject { { "Content-Type", "<content type>" }, { "Filename", "<file name>" }, { "content", "<base 64 encoded content>" } } });