{"action":"opened","issue":{"url":"https://api.github.com/repos/chirag04/mail-listener2/issues/49","labels_url":"https://api.github.com/repos/chirag04/mail-listener2/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/chirag04/mail-listener2/issues/49/comments","events_url":"https://api.github.com/repos/chirag04/mail-listener2/issues/49/events","html_url":"https://github.com/chirag04/mail-listener2/issues/49","id":103322068,"number":49,"title":"Getting from email address in attachments section","user":{"login":"paryasomayajulu","id":4153256,"avatar_url":"https://avatars.githubusercontent.com/u/4153256?v=3","gravatar_id":"","url":"https://api.github.com/users/paryasomayajulu","html_url":"https://github.com/paryasomayajulu","followers_url":"https://api.github.com/users/paryasomayajulu/followers","following_url":"https://api.github.com/users/paryasomayajulu/following{/other_user}","gists_url":"https://api.github.com/users/paryasomayajulu/gists{/gist_id}","starred_url":"https://api.github.com/users/paryasomayajulu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paryasomayajulu/subscriptions","organizations_url":"https://api.github.com/users/paryasomayajulu/orgs","repos_url":"https://api.github.com/users/paryasomayajulu/repos","events_url":"https://api.github.com/users/paryasomayajulu/events{/privacy}","received_events_url":"https://api.github.com/users/paryasomayajulu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-26T17:10:16Z","updated_at":"2015-08-26T17:10:16Z","closed_at":null,"body":"Hi,\r\nfor downloading the attachments i wrote following piece of code. This is working perfectly fine\r\nBut thing is i want to append from email id at the end of each attachment file name at the time of downloading.Something like \"attachment.generatedFileName+'___'+fromemailid \". But i am not able to get from email id or even mail object in the attachments event.\r\n\r\nAlso i thought like  as mail processing is sequential, i thought of taking a variable called fromEmail and fill it with the actual value in \r\nmailListener.on(\"mail\", function(mail, seqno, attributes){})\r\n\r\nand later make use of it in attachments event. But thing is attachments event is firing first and later mail event is firing.\r\n\r\n\r\n mailListener.on(\"attachment\", function(attachment){\r\n        var validDownloadTypes=['application/pdf','application/msword','text/plain','application/rar','application/zip'];\r\n        if(validDownloadTypes.indexOf(attachment.contentType)>=0)\r\n        {\r\n          console.log(\"Downloading attachment to ---  C:\\\\MailDownloads\\\\\"+attachment.generatedFileName);\r\n          var output = fs.createWriteStream(\"C:\\\\MailDownloads\\\\\"+attachment.generatedFileName);\r\n          attachment.stream.pipe(output);\r\n        }\r\n    });"}}