Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node Webkit- opening and sending emails via outlook

I have a cordova app that I want to run on desktops using Node Webkit.

I need to replace cordova.plugins.email() function with a Node Webkit equivelant but am struggling to find the info I need.

Can anyone help?

//email composer
$('#stage').on('click', '#email', function(event){
  var pdfatt = (this.getAttribute('data-pdfemail'));
  var profforename = window.localStorage.getItem('profForename');
  var profsurname = window.localStorage.getItem('profSurname');
  var profemail = window.localStorage.getItem('profEmail');

     cordova.plugins.email.isAvailable(
         function (isAvailable) {  
          cordova.plugins.email.open({
          body:'<p><img src="wp-content/uploads/2016/06/Email_Header.jpg"/></p><br><br>From:<p>'+profforename+' '+profsurname+'</p><p>Tel:'+proftel+'</p><p>Mob: '+profmob+'</p><p>Email: '+profemail+'</p><br><br><a href="'+pdfatt+'"><img height="30px" src='+baseurl+'"/wp-content/uploads/2016/06/download-pdf.jpg"/><br>Click To Download the PDF</a><br><br><br><p><img src="/wp-content/uploads/2016/06/Email_Footer.jpg"/></p>',
          subject: 'subject',
          isHtml: true
           });
              //alert('Service is not available') unless isAvailable;
        }
      );
});

The above code basically opens up a new email and pre-populates the email. I cannot find much information out there on how to do this. I have come across nodemailer but I don't think this is what I need as I would want to open up and email in Outlook and prepopulate, leaving the user to add the email address.

Many thanks

like image 838
LeeTee Avatar asked Jul 27 '16 11:07

LeeTee


1 Answers

oh this is so simple, not sure why I tried to overcomplicate it! Turned out I sneeded to use the Nodewebkit GUI Library.

// Load native Nodewebkit UI library.  
var gui = require('nw.gui');

gui.Shell.openExternal('mailto:[email protected]?subject=test&body=hello');
like image 165
LeeTee Avatar answered Oct 28 '22 02:10

LeeTee