问题描述
我想https://sendgrid.com使用wix.com发送电子邮件,并且一切正常,但是附件为空。为什么?
scanner.useDelimiter("\r?\n");
答案是<input type="file" id='uploadFile1' />
<div onclick='send()'>send</div>
<script>
import {fetch} from 'wix-fetch';
function sendWithService(key,sender,recipient,subject,body,attach) {
const url = "https://api.sendgrid.com/api/mail.send.json";
const headers = {
"Authorization": "Bearer " + key,"Content-Type": "application/x-www-form-urlencoded"
};
var contentfile = attach;
const data = `from=${sender}&to=${recipient}&subject=${subject}&text=${body}&files[download.png]=${contentfile}`;
const request = {
"method": "post","headers": headers,"body": data
};
return fetch(url,request).then(response => response.json());
}
function sendEmail(subject,attach) {
const key = "FDkdfjls__MYUNIQKEY__dsfsdlfs__MYUNIQKEY__asfkjsdf3424";
const sender = "[email protected]";
const recipient = "[email protected]";
return sendWithService(key,attach);
}
function send() {
sendEmail('my subject','my text',document.getElementById('uploadFile1').files[0]).then(response => console.log(response));
}
</script>
,并且字母和主题和文本正确到达,但是文件为空。它由{message: "success"}
或[object,object]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)