Hello guys, I have a form on my website where the customer can upload an image.Then the site sends to him a template email with sendgrid, so I want to show this image uploaded in my email. How can I do that?
UP
I didn’t understand, can a moderator help me?
If you use the sendgrid npm
then in your backend pass the full image url:
export function myFunction(sender, recipient, message, imageUrl) {
sgMail.setApiKey('API KEY');
let msg = {
to: recipient,
from: sender,
templateId: 'template-key',
dynamic_template_data: {
"message": message,
"imageUrl": imageUrl
},
};
sgMail.send(msg);
}
And on sendGrid create an html template with:
<img class="max-width" border="0" style="display:block;color:#000000;text-decoration:none;font-family:Helvetica, arial, sans-serif;font-size:16px;max-width:100% !important;width:100%;height:auto !important;" src={{imageUrl}} alt="" width="180">
P.S. full url is not the wix image source. To retrieve the full url, do:
let imageUrl = "https://static.wixstatic.com/media/" + $w("#image1").src.split("/")[3];
Don’t work
It worked for me. Maybe post your code here…
@jonatandor35 But how to get the url of an image uploaded?
How can I get the url from an image uploaded with the upload button in a database?
Is it a dynamic item page?
then:
$w.onReady( () => {
$w("#dynamicDataset").onReady( () => {
let imageSrc = $w("#dynamicDataset").getCurrentItem().image;
let imageUrl = "https://static.wixstatic.com/media/" + imageSrc.split("/")[3];
})
})
@jonatandor35 No it isn’t a dynamic page
@fraspace5 so add details. What data do you have? What would you like to happen?
@jonatandor35 I have an upload button, with this button I send to a database the image, but always in the same page I send an email with that image
let imageUrl;
//code..code...use your uploadButton code...then:
$w("#myUploadButton").startUpload()
.then( (uploadedFile) => {
imageUrl = "https://static.wixstatic.com/media/" + uploadedFile.url.split("/")[3];
} )