Loopback send Email with attachment from another m

2019-08-18 03:17发布

I have form where i can able to save the file in some location and can store the values in the database.Now i have the email connector where i can fetch the values of the form and send it through email. I have two models one is for storing the values in the database i.e PersistedModel and the other is for storing the attachment now i want to send an email with attachment. how to send can anyone help me.

career.js

'use strict';
const app = require('../../server/server');
module.exports = function(Career) {
    Career.afterRemote('create', function(context, remoteMethodOutput, next) { 
        next(); 

Contact.app.models.Email.send({ 
    to: 'lakshmipriya.l@company.com', 
    from: 'lakshmipriya.l@gmail.com', 
    subject: 'my subject', 
    text: 'my text', 
    html: 'my <em>html</em>',
 attachments: [
    {  
      path: /path/to/remoteMethodOutput.resume
    }
],
    }, function(err, mail) { 
    console.log('email sent!'); 
    cb(err); 
    }); 
    }); 

};

I tried this but its not working because the resume is in another attachment module. so i could not fetch the resume. how to fetch and attach the file.

0条回答
登录 后发表回答