Email 用Mandrill发送附件
我正试图发送一份与曼德里尔的附件。我已将此添加到我的对象中:Email 用Mandrill发送附件,email,base64,email-attachments,mandrill,Email,Base64,Email Attachments,Mandrill,我正试图发送一份与曼德里尔的附件。我已将此添加到我的对象中: "attachments": [ { "type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "name": "filename-removed.docx" "content": attachment } ] 附件是我将文件上载到此bas
"attachments": [
{
"type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"name": "filename-removed.docx"
"content": attachment
}
]
附件是我将文件上载到此base64转换器时得到的一个巨大字符串:
我得到了这个错误:
Uncaught SyntaxError: Unexpected string
我尝试将字符串粘贴到那里,并将其设置为变量(如上所述),但我一直遇到这个错误。有没有更简单的方法?我做错了什么?不要粘贴字符串,而是尝试直接操作文件并将其编码为base64。在Python中:
import base64
file = open(path/to/file.docx)
encoded = base64.b64encode(file.read())
file.close()
然后将附件设置为encoded
,您就可以开始了
或者,您可能只需要在“filename removed.docx”
之后加一个逗号