The sendgrid training video includes the ability to send photographs as attachments, the available plugin does not include the photo upload ability, Is the other plugin available somewhere?
The sendgrid training video includes the ability to send photographs as attachments, the available plugin does not include the photo upload ability, Is the other plugin available somewhere?
I understand that the plugin is just a sample app, but is there any sample code that shows how attachments work with appery
I have created a pdf which is stored in a javascript variable as a dataurl. I need to email this as an attachment
I have looked at the plugin, and it seems to make a call to non existent server code. As far as I can see it doesn't do much. I can't find any supporting docs either.
I notice in the sample server code, it asks for the sendgrid api key, but not the username, surely the username is also required?
pre// This script sends an email using SendGrid API.
// To test the script, enter 'to', 'subject', 'text' params in
// Script parameters tab
// SendGrid mail endpoint
var sendGridUrl = "https://api.sendgrid.com/api/mail.send.json";
// Valid to email
var to = request.get ("to");
// Email subject
var subject = request.get("subject");
// Email body
var text = request.get("text");
// Valid from email (from your domain)
var from = "terry@mrtaxsoftware.com";
// Set SendGrid API Key
var auth = "Bearer " + "api_key"; // what is this api_key, is it the sendgrid api_key?
var XHRResponse = XHR2.send("POST", sendGridUrl, {
"parameters": {
"to": to,
"subject": subject,
"text": text,
"from": from
},
"headers" : {
"Authorization": auth
}
});
Apperyio.response.success(XHRResponse.body, "application/json");/pre
Is this the sendgrid V2 or V3 API. According to sendgrids docs V2 seems to require username and api key where as V3 seems to only require the key, Your sendgrid url seems to be for the V2 API, but the authorization looks to be for V3 API. Confused.
How do I include an attachment?
Thanks Max,
Can you let me know when the plugin has been updated?
This is what I have come up with...
Can you let me know if it looks ok?
pre/**
Code: Select all
var formData = new FormData();
var sendGridFileName = imageName + '.' + imageType;
formData.append('files[' + sendGridFileName + ']', blob);
if (datasource && datasource.service) {
try {
datasource.execute({
'allowDataModification' : false,
'processData' : false,
'contentType' : false,
'body' : formData,
'cache' : false
});
} catch (exception) {
console.log(exception.name + ' ' + exception.message);
hideSpinner();
}
} else {
console.warn('This data source is not correct');
}
} else {
console.warn('image data is empty or has a wrong format.');
}
}/pre