I am using the official C# Mailjet SDK (https://github.com/mailjet/mailjet-apiv3-dotnet). Works fine so far.
But how do I add attachments?
I see
Mailjet.Client.Resources
has InlineAttachments and Attachments, but how do I use it?
This is the code snippet so far:
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() } } });
Tried sth. like
request.Property(Send.Attachments, "path/to/file.zip");
But that does not work.
Update
Works like this:
.Property(Send.Attachments, new JArray { new JObject { { "Content-Type", "<content type>" }, { "Filename", "<file name>" }, { "content", "<base 64 encoded content>" } } });
It appears that the naming is a bit different, this worked for me in 2022 with the API v3
Mind the capitalization of some letters (or the lack thereof...)! Note: content field is base64 encoded filedata.