express-server/express-api-server/email/main.js
/**
 * Send Message.
 *
 * @param  {String} userId User's email address. The special value 'me'
 * can be used to indicate the authenticated user.
 * @param  {String} email RFC 5322 formatted String.
 * @param  {Function} callback Function to call when the request is complete.
 */
Send Message.
@param  {String} userId User's email address. The special value 'me'
can be used to indicate the authenticated user.
@param  {String} email RFC 5322 formatted String.
@param  {Function} callback Function to call when the request is complete.
Send Message . @param { String } userId User ' s email address . The special value ' me ' can be used to indicate the authenticated user . @param { String } email RFC 5322 formatted String . @param { Function } callback Function to call when the request is complete .
function sendEmail(OAuth2Client,user_data) {
    let message = createEmail(user_data.userId, user_data.receiverID, user_data.subject, user_data.emailBody);
    const gmail = google.gmail({version: 'v1',OAuth2Client});
    var request = gmail.users.messages.send({
        auth: OAuth2Client, 
        'userId': user_data.userId,
        'resource': {
        'raw': message
        }, function (err, response){
            if (err) console.error(err);
            else console.log(response);
        }
    });
}
function sendEmail ( OAuth2Client , user_data ) { let message = createEmail ( user_data . userId , user_data . receiverID , user_data . subject , user_data . emailBody ) ; const gmail = google . gmail ( { version : 'v1' , OAuth2Client } ) ; var request = gmail . users . messages . send ( { auth : OAuth2Client , 'userId' : user_data . userId , 'resource' : { 'raw' : message } , function ( err , response ) { if ( err ) console . error ( err ) ; else console . log ( response ) ; } } ) ; }
Send Message.
Send Message .