SendEmail
Description
Creates a PDF from base64 encoded HTML and emails it to the provided recipients.
Syntax
VabletNativeInterface.callNativeMethod(
"SendEmail",
{
to,
cc,
bcc,
subject,
body,
company,
queueIfNotAbleToSend,
attachmentDataBase64Encoded,
attachmentName,
disableEmailTemplate,
disableAttachment
},
(res) => {...}
);
Options
| Key | Type | Description |
|---|---|---|
| to cc bcc |
stringobjectarray |
The to, cc, and bcc fields accept an email, an array of emails, or an array of objects. Example: [{name:'Name', email:'email@email.com}] |
| subject | string |
Subject line for the email. |
| body | string |
The email message. This is placed inside the body of your set email template for vablet. |
| company | string |
Company name of the email recipient. This is an optional field used for logging and analytics. |
| queueIfNotAbleToSend | boolean |
If this is set to true the email will attempt to resend until it successfully is sent. Useful for offline emailing. |
| attachmentDataBase64Encoded | base64 |
The base64 encoded data to be sent as an email attachment. |
| attachmentName | string |
The name of the attached file. |
| disableEmailTemplate | boolean |
Disables your custom email template and sends the email body as is. |
| disableAttachment | boolean |
Disable email attachments |
Response
| Key | Type | Description |
|---|---|---|
| success | boolean |
Returns true on success and false for any errors.Always true if queueIfNotAbleToSend is set to true |
| error | string |
Error message, provided there is one. |
Example
VabletNativeInterface.callNativeMethod(
"SendEmail",
{
to: 'email@email.com',
cc: ['1@email.com', '2@email.com'],
bcc: [{name: 'Name 1', email: '1@email.com'},{name: 'Name 2', email: '2@email.com'}],
subject: 'Sample vablet email',
body: 'Find attached your document!',
company: 'Recipient Company',
queueIfNotAbleToSend: true,
attachmentDataBase64Encoded: btoa('Hello World'), // convert data to base64
attachmentName: 'Hello World.txt',
disableEmailTemplate: false,
disableAttachment: false
},
(res) => {
if (res.success) {
// Success!
alert('Email sent successfully!')
} else {
// Uh oh, let's alert the error!
alert(res.error)
}
}
);