outlook邮件发送格式以及附件格式转化

自用备忘录
const readFileAsBase64 = (file: any) => {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.onload = function(e) {
      const imgBase64 = e.target?.result;
      resolve(imgBase64);
    };
    reader.onerror = function(error) {
      reject(error);
    };
    reader.readAsDataURL(file);
  });
};
const uploadImages = async () => {
  if (sendMailQuery.value.files.length < 1) {
    return;
  }
  // 遍历文件列表
  for (const files of sendMailQuery.value.files) {
    let file = files.raw;
    if (file) {
      proxy?.$modal.loading("正在上传文件,请稍候...");
      // 读取文件为 Base64 编码
      const imgBase64:any = await readFileAsBase64(file);
      // console.log(file.type);
      // 将读取到的 Base64 编码添加到附件列表中
      queryImgFalse.value.push({
        name: file.name,
        contentType: file.type,
        contentBytes: imgBase64.replace(/^data:.+;base64,/, ""),
        isInline: false,
        contentId: file.name,
        size: file.size
      });
    }
  }
  proxy?.$modal.closeLoading();
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值