welcome, I am trying to send email with attachment (.png or .pdf) no success so far. regular emails are sent though. Is there a way to send attachments using Wix? thanks!
This is the text that appears in email body: [object Object]
Here is part of the code:
function sendFormData(attachment) {
var attachments = [{
‘filename’: ‘filename.png’,
‘content’: attachment,
‘contentType’: ‘application/png’
}]
var counter = 0,
attach = [];
attach.push(attachments);
const subject = test subject
;
const body = attach;
const recipient = ‘example@gmail.com’;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
}
#sendgrid #email #attachment
1 Like
Wix sites do not support a “standard” file system for the site. Where are the files that you wish to attach?
thanks for a response! I am generating file at runtime.
@davitgoderdzishvili1 Wix Code does not support a “standard” file system, so there’s really no place to save the file - and therefore no path name.
I am taking a snapshot of html canvas. then I want to send this image via email. is there a way to achieve this functionality using wix? this is crustal part of the website we are working on.
@davitgoderdzishvili1 What do you mean by “html canvas”?
@Yisrael (Wix)
This is how I get image from html, it is generating image url (this logic is inside HTML iframe), I am sending this string to wix page using window.parent.postMessage(doc, “*”); so data is there. Now I want to embed generated image in email as an attachment.
I think only way would be to host file using external sever and attach a link.
@davitgoderdzishvili1 Aha - now I understand. However, doesn’t help much. As I mentioned before, the image has no path in the file system. You can see Steve Cropper’s post which explains how to download a file - but this has to be done from an HtmlComponent.
Yes, this logic is in html component
In my comments about Steve Cropper’s post above, I mean that the actual download is done from the HtmlComponent. Downloading or emailing a file cannot be done from Wix Code.
@yisrael-wix thanks for clarification, now I am planning to save image on wix database and share link, this should work right?
This still does not work because image urls are local to wix.