Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- makeBody(){
- var arr = [];
- for(var i=0;i<this.attachment.length;i++){
- arr[i] = {
- path: this.attachment[i],
- encoding: 'base64'
- }
- }
- //Mail Body is created.
- if(this.attachment.length){
- let mail = new mailComposer({
- to: this.to,
- text: this.body,
- subject: this.sub,
- textEncoding: "base64",
- attachments: arr
- });
- }
- else{
- let mail = new mailComposer({
- to: this.to,
- text: this.body,
- subject: this.sub,
- textEncoding: "base64"
- });
- }
- //Compiles and encodes the mail.
- mail.compile().build((err, msg) => {
- if (err){
- return console.log('Error compiling email ' + error);
- }
- const encodedMessage = Buffer.from(msg)
- .toString('base64')
- .replace(/\+/g, '-')
- .replace(/\//g, '_')
- .replace(/=+$/, '');
- if(this.task === 'mail'){
- this.sendMail(encodedMessage);
- }
- else{
- this.saveDraft(encodedMessage);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement