showing results for - "smtpjs attachment"
Emiliano
04 Nov 2018
1<html>
2<script src="https://smtpjs.com/v3/smtp.js"></script>
3<input type="file" id="fileupload" onchange="uploadFileToServer()" />
4<script>
5function uploadFileToServer()
6{
7  var file = event.srcElement.files[0];
8   var reader = new FileReader();
9   reader.readAsBinaryString(file);
10   reader.onload = function () {
11       var dataUri = "data:" + file.type + ";base64," + btoa(reader.result);
12       Email.send({
13           SecureToken : "********",
14           To : 'info@destination.com',
15           From : "you@source.com",
16           Subject : "Send with base64 attachment",
17           Body : "Sending file:" + file.name,
18           Attachments : [
19          	{
20          		name : file.name,
21          		data : dataUri
22          	}]
23       }).then(
24         message => alert(message)
25       );
26   };
27   reader.onerror = function() {
28       console.log('there are some problems');
29   };
30}
31</script>
32</html>