Scandit.Email

Methods

(static) off(arg: (string | function))

Removes event listener. Possible events: success, fail

Parameters:
Name Type Description
arg string | function

Event name or callback function

Examples
  • JavaScript
  • ES6
Scandit.Email.off('success');
Scandit.Email.off('success');
  • JavaScript
  • ES6
Scandit.Email.off('fail');
Scandit.Email.off('fail');

(static) on(event: string, callback: function)

Adds event listener. Possible events: success, fail

Parameters:
Name Type Description
event string

Event name

callback function

Event callback

Examples
  • JavaScript
  • ES6
Scandit.Email.on('success', function(emailId) {
  console.log('Email (' + emailId + ') sent');
});
Scandit.Email.on('success', emailId => {
  console.log(`Email ${emailId} sent`);
});
  • JavaScript
  • ES6
Scandit.Email.on('fail', function(emailId) {
  console.log('Email (' + emailId + ') could not be sent');
});
Scandit.Email.on('fail', emailId => {
  console.log(`Email ${emailId} could not be sent`);
});

(static) send(subject: string, message: string, recipients: string[], options?: object): Promise

Sends an email

Parameters:
Name Type Attributes Default Description
subject string

Email subject

message string

Email message

recipients string[]

List of recipients

options object <optional>
{}

Options

Properties
Name Type Attributes Default Description
attachments object <optional>
{}

Attachments as {filename: fileurl, ...}

senderName string <optional>

Name of the sender

useDefaultTemplate boolean <optional>
true

Whether email should be sent in the platform html template or not.

synchronous boolean <optional>
false

If true - device must be online. If false - request will be added to the queue and processed as soon as possible.

Returns:
Promise

Promise

Examples
Send email synchronously
  • JavaScript
  • ES6
Scandit.Email.send('Subject', 'Hello world!', ['contact@scandit.com'], { synchronous: true })
.then(function() {
  console.log('Email sent!');
}).catch(function(reason) {
  console.log('Email could not be sent because ' + reason);
});
Scandit.Email.send('Subject', 'Hello world!', ['contact@scandit.com'], { synchronous: true })
.then(() => {
  console.log('Email sent!');
}).catch(reason => {
  console.log(`Email could not be sent because ${reason}`);
});
Send email asynchronously
  • JavaScript
  • ES6
Scandit.Email.on('success', function(emailId) {
  console.log('Email (' + emailId + ') sent');
});

Scandit.Email.on('fail', function(emailId) {
  console.log('Email (' + emailId + ') could not be sent');
});

Scandit.Email.send('Subject', 'Hello world!', ['contact@scandit.com'])
.then(function(emailId) {
  console.log('Email (' + emailId + ') added to queue');
})
.catch(function(reason) {
  console.log('Email could not be added to queue, reason: ' + reason);
});
Scandit.Email.on('success', emailId => {
  console.log(`Email ${emailId} sent`);
});

Scandit.Email.on('fail', emailId => {
  console.log(`Email ${emailId} could not be sent`);
});

Scandit.Email.send('Subject', 'Hello world!', ['contact@scandit.com'])
.then(emailId => {
  console.log(`Email ${emailId} added to queue`);
})
.catch(reason => {
  console.log(`Email could not be added to queue, reason: ${reason}`);
});

Events

fail

An email failed to send

Examples
  • JavaScript
  • ES6
Scandit.Email.on('fail', function(emailId) {
  console.log('Email (' + emailId + ') could not be sent');
});
Scandit.Email.on('fail', emailId => {
  console.log(`Email ${emailId} could not be sent`);
});

success

An email was successfully sent

Examples
  • JavaScript
  • ES6
Scandit.Email.on('success', function(emailId) {
  console.log('Email (' + emailId + ') sent');
});
Scandit.Email.on('success', emailId => {
  console.log(`Email ${emailId} sent`);
});