email - 您将如何使用 MailJet api 附加 excel 文档
问题描述
您好,我尝试使用 mailjets api 发送 excel 文档。我首先使用 mailjets 库将 excel 文件编码为 base64。然后我使用 mailjets 库将文件添加为附件并设置 mime 类型 application/vnd.ms-excel。这是一个例子。
request = new MailjetRequest(Emailv31.resource)
.property(Emailv31.MESSAGES, new JSONArray()
.put(new JSONObject()
.put(Emailv31.Message.FROM, new JSONObject()
.put("Email", "pilot@mailjet.com")
.put("Name", "Mailjet Pilot"))
.put(Emailv31.Message.TO, new JSONArray()
.put(new JSONObject()
.put("Email", "passenger1@mailjet.com")
.put("Name", "passenger 1")))
.put(Emailv31.Message.SUBJECT, "Your email flight plan!")
.put(Emailv31.Message.TEXTPART, "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!")
.put(Emailv31.Message.HTMLPART, "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!")
.put(Emailv31.Message.ATTACHMENTS, new JSONArray()
.put(new JSONObject()
.put("ContentType", "application/vnd.ms-excel")
.put("Filename", "test.txt")
.put("Base64Content", "excelFileBase64")))));
response = client.post(request);
但是,我总是收到文件,因为它的字符串表示 base64 编码。
解决方案
推荐阅读
- typescript - Karma 中的源映射 TypeScript
- php - 无法加载动态库 'zip' php - ArchLinux
- c# - 返回 0 的数据表。位置 2 处没有行 ASP.NET
- azure - Microsoft Azure 认知服务 LUIS 未显示用户在审阅端点话语中输入的内容
- javascript - 如果任何用户在页面上,则锁定表单
- ios - 如何以编程方式复制 UIView 并保存accessibilityId?
- binary - 二进制补码 VHDL
- javascript - 有没有办法让“onPress”和“onLongPress”在同一个“Button/TouchableOpacity”上
- python - 跳过所有包含字符串的行,只保留带有浮点数的行
- google-chrome-extension - 如何使用 chrome.identity.launchWebAuthFlow 缓存身份验证令牌?