Guest User

Untitled

a guest
Oct 29th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. emailInvoice () {
  2. Axios({
  3. method: 'post',
  4. url: 'http://myApi/api/html-to-pdf',
  5. data: {
  6. html: this.getInvoiceHtml()
  7. },
  8. responseType: 'blob'
  9. }).then(function (pdfResponse) {
  10. Axios.post('http://localhost:4000/api/send-email', {
  11. host: '##',
  12. port: '26',
  13. user: '##',
  14. pass: '##',
  15. to: '##',
  16. from: '##',
  17. subject: 'Invoice ' + this.model.doc.ref,
  18. text: 'Test Text',
  19. html: '<b>TEST</b>',
  20. attachments: [{
  21. filename: this.model.doc.ref + '.pdf',
  22. content: pdfResponse.data,
  23. contentType: 'application/pdf'
  24. }]
  25. }).then(function (response) {
  26. console.log('Email Success')
  27. console.log(response)
  28. }).catch(function (error) {
  29. console.log('Email Error')
  30. console.log(error)
  31. })
  32. }.bind(this)).catch(function (error) {
  33. console.log('PDF Error')
  34. console.log(error)
  35. })
  36. }
Add Comment
Please, Sign In to add comment