I’m trying to experiment with the example code covering sending emails using Javascript and running it through Node.js on my terminal to be able to send it to users of the app. However, I am getting a reference error when I am using the code that is found in the documentation.
This is the following code that I have currently.
require('backendless');
var APPLICATION_ID = '*hidden*',
SECRET_KEY = '*hidden*',
VERSION = 'v1'; //default application version;
Backendless.initApp(APPLICATION_ID, SECRET_KEY, VERSION);
var successCallback = function( response )
{
console.log( "[ASYNC] message has been sent" );
};
var failureCallback = function( fault )
{
console.log( "error - " + fault.message );
};
// prepare message bodies (plain and html) and attachment
var bodyParts = new Bodyparts();
bodyParts.textmessage = "Check out this awesome code generation result";
bodyParts.htmlmessage = "Check out this <b>awesome</b> code generation result";
var attachments = ["backendless-codegen.zip" ];
// asynchronous call
var responder = new Backendless.Async( successCallback, failureCallback );
Backendless.Messaging.sendEmail( "Backendless code gen", bodyParts, [ "jjtorlino@yahoo.com" ], attachments, responder );
It is the same exact code except for the first 5 lines and it results in this error when I am running it.
var bodyParts = new Bodyparts();
^
ReferenceError: Bodyparts is not defined
at Object.<anonymous> (/Users/JeregoOrlino/Desktop/PiSprinkler/notifications.js:18:21)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function.Module.runMain (module.js:441:10)
at startup (node.js:139:18)
at node.js:968:3
I was wondering if I could get help on this?
Thank you in advance