Guest User

Untitled

a guest
May 1st, 2018
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. From 1594455689612692529@xxx Fri Mar 09 10:30:39 +0000 2018
  2. X-GM-THRID: 1594455689612692529
  3. Message-ID: <0620b50c-1f22-4513-b595-7b64c9632c67@abc-mail.com>
  4. X-Mailgun-Track-Clicks: no
  5. From: "Dennis" <notifications@abc-mail.com>
  6. X-Mailgun-Track-Opens: no
  7.  
  8. function extractNames(text) {
  9. return text.match(/(From: [^>]* <notifications@abc-mail.com>)/gi);
  10. }
  11.  
  12. //body
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w
  14. 3.org/TR/REC-html40/loose.dtd">=0A<html>=0A ..etc
  15.  
  16. ... there is too much text and here is the email of the user
  17.  
  18.  
  19. padding: 0"><a href=3D"mailto:dennis.bra@marketics.com" st=
  20. yle=3D"color: default; text-decoration: underline">dennis.brahg@marketics.com</a></td>=0A<td style=3D"
  21.  
  22. ... there is could be 1 email but also could be 2 or 3 of them
  23.  
  24. padding: 0"><a href=3D"dennis.bra@gmail.com" st=
  25. yle=3D"color: default; text-decoration: underline">dennis.bra@gmail.com</a></td>=0A<td style=3D"
  26.  
  27. function extractEmails (text) {
  28. let txt = text.replace(/=/gi, "");
  29. txt = txt.replace(/r?n|r/g, "");
  30. txt = txt.replace(/( )/g, "");
  31. return txt.match(/(font-weight:normal;padding:0"><ahref3D"mailto:[sS]*?"style3D"color:default;text-decoration:underline">)/gi);
  32. }
  33.  
  34. fs.readFile('MESSAGES.txt', function (err, data) {
  35. if (err) return console.error(err);
  36.  
  37. EMAILS = extractEmails(data.toString());
  38. NAMES = extractNames(data.toString());
  39.  
  40. }
  41.  
  42. EMAILS = EMAILS.map(item => {
  43. item = item.replace(/font-weight:normal;padding:0"><ahref3D"mailto:/gi, '');
  44. item = item.replace(/"style3D"color:default;text-decoration:underline">/gi, '');
  45. return item ? item : 'NO EMAIL PROVIDED';
  46. });
  47. NAMES = NAMES.map(item => {
  48. item = item.replace(/notifications@intercom-mail.com>/gi, '');
  49. return item.replace(/^From: /gi, '').replace(/["<]/gi, '');
  50. });
  51.  
  52. let SUM = [];
  53. for (let i = 0; i < EMAILS.length; i++) {
  54. SUM.push(`${NAMES[i]} ${EMAILS[i]} rn`);
  55. }
  56. fs.writeFile('SUM.txt', SUM, function(err) {
  57. if (err) return console.error(err);
  58. console.log("SUM written successfully!");
  59. });
Add Comment
Please, Sign In to add comment