[英]Send Email with attachment file (more than 10 MB) using GMAIL API in Javascript
How to Send Email with an attachment PDF file (more than 10 MB) using GMAIL API in Javascript. 我尝试使用 PDF 文件附件的一些代码并发送 email 如下。
const base64Data = 'Base64 PDF File string here (10 MB)'
const mixedB = 'mixedB';
const relatedB = 'relatedB';
const alternativeB = 'alternativeB';
const To = 'test@gmail.com'
const message = '<p>This is TEST EMAIL with PDF Attachment</p>'
const messageParts = [
'From: ' + 'vijay@test.com',
'To: ' + To,
`Subject: This is Test Email`,
'MIME-Version: 1.0',
'Content-Type: multipart/mixed; boundary="' + mixedB + '"',
'',
'--' + mixedB,
'Content-Type: multipart/related; boundary="' + relatedB + '"',
'',
'--' + relatedB,
'Content-Type: multipart/alternative; boundary="' + alternativeB + '"',
'',
'--' + alternativeB,
'Content-Type: text/html; charset=utf-8',
'',
message, // html content.
'',
'--' + alternativeB + '--',
'',
'--' + relatedB + '--',
'',
'--' + mixedB,
'Content-Type: application/pdf;name="attachedFile.pdf"',
'Content-Transfer-Encoding: base64',
'Content-Disposition: attachment;filename="attachedFile.pdf"',
'',
base64Data, // base64 data of the file.
'',
'--' + mixedB + '--'
]
let aaa = messageParts.join('\r\n')
var sendRequest = gapi.client.gmail.users.messages.send({
'userId': 'me',
'uploadType': 'multipart',
'resource': {
'raw': window.btoa(aaa).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
}
});
return sendRequest.execute();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.