Hi friends. I was trying to find a solution to this but it was impossible. this problem i am having:
I have a security camera installed to which I configure email alarm. the camera sends to my email inbox (gmail) the image captured by the camera when it detects a movement. so far so good.
I'm not going to be checking email notifications all day, it occurred to me to try to do something with node red + telegram bot + email, but my results were not entirely satisfactory.
Basically what I cannot is extract the attached file (image capture) that arrives in the email, I only see the name of the file but I want to extract it to send it by telegram-bot.
so I have the flow
[{"id":"385d22b5af68ccec","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"1f7cb2cb9e6e0bb5","type":"e-mail in","z":"385d22b5af68ccec","name":"","protocol":"IMAP","server":"imap.gmail.com","useSSL":true,"autotls":"never","port":"993","box":"INBOX","disposition":"Read","criteria":"UNSEEN","repeat":"5","fetch":"auto","inputs":0,"x":130,"y":80,"wires":[["bf8341d7380b2ffb","1916f5220e18b96c","e31de8d64003fa89"]]},{"id":"796e2e5f3b8ebe23","type":"telegram sender","z":"385d22b5af68ccec","name":"Notificar posición","bot":"7ce3197fa4cd33f0","haserroroutput":false,"outputs":1,"x":570,"y":40,"wires":[[]]},{"id":"bf8341d7380b2ffb","type":"function","z":"385d22b5af68ccec","name":"MSJ FEDE","func":"\nvar message = '*Notificación de evento captado en la Camara: *' + '```'+ msg.header.subject +'```'+ '\\r\\n' + '\\r\\n' +\n'Evento registrado con fecha:' + msg.header.date + '\\r\\n' + '\\r\\n' +\nmsg.payload + '\\r\\n' +\n'Nombre de la imagen:' + 'T21082620000900.jpg';\n// Configuramos el payload\nmsg.payload = {chatId: 280139301, type : 'message', content : message};\n\n\nmsg.payload.options = {disable_web_page_preview : true, parse_mode : \"Markdown\"};\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":40,"wires":[["796e2e5f3b8ebe23"]]},{"id":"1916f5220e18b96c","type":"function","z":"385d22b5af68ccec","name":"IMG FEDE","func":"msg.payload = {\ncontent : 'https://www.denverpost.com/wp-content/uploads/2018/10/security-camera-footage.jpg',\ntype : 'photo',\nchatId : '280139301',\ncaption : msg.header.subject\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":100,"wires":[["02028185eeeb29a3"]]},{"id":"4e28af6677e23ebd","type":"telegram sender","z":"385d22b5af68ccec","name":"","bot":"7ce3197fa4cd33f0","haserroroutput":false,"outputs":1,"x":670,"y":140,"wires":[[]]},{"id":"02028185eeeb29a3","type":"delay","z":"385d22b5af68ccec","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":480,"y":100,"wires":[["4e28af6677e23ebd"]]},{"id":"e31de8d64003fa89","type":"debug","z":"385d22b5af68ccec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":340,"y":200,"wires":[]},{"id":"7ce3197fa4cd33f0","type":"telegram bot","botname":"Camaras xxxxxx xxxxx","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]
and the result that I get every time an email arrives is:
{"payload":"Se ha detectado un movimiento en la camra denominada \"Frente Balcon\".\n","topic":"Frente Balcon","date":"2021-08-27T01:26:12.000Z","header":{"return-path":{"value":[{"address":"federicobalm@gmail.com","name":""}],"html":"<span class=\"mp_address_group\"><a href=\"mailto:federicobalm@gmail.com\" class=\"mp_address_email\">federicobalm@gmail.com</a></span>","text":"federicobalm@gmail.com"},"received":"from smtp.gmail.com ([181.46.9.228]) by smtp.gmail.com with ESMTPSA id v8sm2785157qtk.49.2021.08.26.18.26.13 for <federicobalm@gmail.com> (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Aug 2021 18:26:25 -0700 (PDT)","message-id":"<61283f41.1c69fb81.52e5.4e79@mx.google.com>","x-google-original-message-id":"163002757","from":{"value":[{"address":"federicobalm@gmail.com","name":"<Frente Balcon>"}],"html":"<span class=\"mp_address_group\"><span class=\"mp_address_name\"><Frente Balcon></span> <<a href=\"mailto:federicobalm@gmail.com\" class=\"mp_address_email\">federicobalm@gmail.com</a>></span>","text":"<Frente Balcon> <federicobalm@gmail.com>"},"x-google-original-from":"<Frente Balcon>","date":"2021-08-27T01:26:12.000Z","to":{"value":[{"address":"federicobalm@gmail.com","name":""}],"html":"<span class=\"mp_address_group\"><a href=\"mailto:federicobalm@gmail.com\" class=\"mp_address_email\">federicobalm@gmail.com</a></span>","text":"federicobalm@gmail.com"},"subject":"Frente Balcon","x-mailer":"SMTPC","mime-version":"1.0","content-type":{"value":"multipart/mixed","params":{"boundary":"*********hichip_splite_flag*********"}}},"from":"federicobalm@gmail.com","attachments":[{"type":"attachment","content":[255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,1,0,1,0,0,255,254,0,5,0,0,0,255,219,0,67,0,10,7,7,8,7,6,10,8,8,8,11,10,10,11,14,24,16,14,13,13,14,29,21,22,17,24,35,31,37,36,34,31,34,33,38,43,55,47,38,41,52,41,33,34,48,65,49,52,57,59,62,62,62,37,46,68,73,67,60,72,55,61,62,59,255,254,0,5,0,0,0,255,219,0,67,1,10,11,11,14,13,14,28,16,16,28,59,40,34,40,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,255,192,0,17,8,4,56,7,128,3,1,34,0,2,17,1,3,17,1,255,196,0,31,0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,254,0,5,0,0,0,255,196,0,181,16,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125,1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250,255,254,0,3,0,255,196,0,31,1,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,254,0,5,0,0,0,255,196,0,181,17,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119,0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250,255,254,0,6,0,0,0,0,255,218,0,12,3,1,0,2,17,3,17,0,63,0,143,195,158,26,62,32,251,79,250,87,217,252,141,191,242,207,118,236,231,220,122,86,231,252,43,129,255,0,65,95,252,151,255,0,236,169,126,29,241,253,163,255,0,108,191,246,122,139,198,250,133,237,174,181,12,118,215,151,16,33,183,82,86,57,89,65,59,155,156,3,93,119,57,137,63,225,92,143,250,10,255,0,228,191,255,0,101,88,126,35,240,231,246,1,182,255,0,75,251,71,159,187,254,89,237,219,140,123,159,90,169,253,183,170,143,249,138,94,127,223,246,255,0,26,173,115,125,119,121,183,237,87,83,79,179,59,124,217,11,99,61,113,159,165,32,32,197,46,113,94,129,109,225,61,46,243,195,208,203,29,170,139,185,173,21,150,70,149,240,28,167,82,51,235,237,75,15,134,252,49,104,162,210,238,88,101,186,141,115,33,123,130,140,120,220,78,208,220,12,115,244,252,232,3,207,115,197,38,106,244,26,123,235,26,187,219,233,112,176,142,73,24,160,127,249,102,153,224,177,231,160,199,175,227,93,184,240,159,135,116,235,56,255,0,180,54,22,31,43,79,52,198,48,237,215,166,224,7,211,219,189,33,158,114,77,33,60,215,160,222,120,55,72,212,44,124,221,37,214,39,193,242,221,37,47,27,156,247,206,125,8,227,167,191,74,224,103,133,237,174,36,130,85,219,36,76,81,215,57,193,7,6,144,49,152,230,144,241,94,129,15,133,180,203,143,13,71,60,54,91,175,37,179,14,141,230],"contentType":"image/jpeg","partId":"2","release":null,"contentDisposition":"attachment","filename":"A21082622260720.jpg","headers":{"content-type":{"value":"image/jpeg","params":{"name":"A21082622260720.jpg"}},"content-disposition":{"value":"attachment","params":{"filename":"A21082622260720.jpg"}},"content-transfer-encoding":"Base64"},"checksum":"03f8d127277d60c077f7e05f85c03d19","size":302031},{"type":"attachment","content":[255,216,255,224,0,16,74,70,73,70,0,1,1,0,0,1,0,1,0,0,255,254,0,5,0,0,0,255,219,0,67,0,10,7,7,8,7,6,10,8,8,8,11,10,10,11,14,24,16,14,13,13,14,29,21,22,17,24,35,31,37,36,34,31,34,33,38,43,55,47,38,41,52,41,33,34,48,65,49,52,57,59,62,62,62,37,46,68,73,67,60,72,55,61,62,59,255,254,0,5,0,0,0,255,219,0,67,1,10,11,11,14,13,14,28,16,16,28,59,40,34,40,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,59,255,192,0,17,8,4,56,7,128,3,1,34,0,2,17,1,3,17,1,255,196,0,31,0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,254,0,5,0,0,0,255,196,0,181,16,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125,1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250,255,254,0,3,0,255,196,0,31,1,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,255,254,0,5,0,0,0,255,196,0,181,17,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119,0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250,255,254,0,6,0,0,0,0,255,218,0,12,3,1,0,2,17,3,17,0,63,0,143,195,158,27,255,0,132,131,237,31,233,127,103,242,54,255,0,203,61,251,179,159,113,233,91,159,240,174,57,255,0,144,175,254,75,255,0,246,84,191,14,184,26,143,253,178,255,0,217,234,47,27,234,55,182,186,212,49,219,94,92,64,134,221,73,88,229,101,4,238,110,112,13,117,156,196,159,240,174,71,253,5,127,242,95,255,0,178,172,63,18,120,115,251,0,219,127,165,253,163,207,221,255,0,44,246,237,198,61,207,173,83,58,222,170,63,230,41,121,255,0,129,13,254,53,94,230,254,238,243,111,218,174,166,159,102,118,249,178,22,198,122,227,63,74,67,32,197,46,112,43,208,45,124,39,165,222,120,122,25,99,181,2,238,107,69,101,145,165,124,7,41,193,35,62,190,212,176,248,111,195,22,170,45,46,164,134,91,168,215,50,23,184,40,199,141,196,237,13,192,199,63,79,206,129,30,122,77,38,106,245,190,158,250,190,174,246,250,92,44,35,121,24,160,115,254,173,51,193,99,207,65,143,95,198,187,129,225,63,14,233,214,81,255,0,104,108,44,62,86,158,105,140,97,219,175,77,192,15,167,183,122,67,60,231,52,210,121,175,65,188,240,110,145,168,88,249,186,75,172,79,131,229,186,74,94,55,57,239,146,125,8,227,245,233,92,12,240,189,181,196,144,74,187,100,141,138,58,231,56,32,224,210,24,204,102,144,241,94,129,15,133,180,203,143,13,71,60,54,91,175,37,179,14,141,230],"contentType":"image/jpeg","partId":"3","release":null,"contentDisposition":"attachment","filename":"A21082622260821.jpg","headers":{"content-type":{"value":"image/jpeg","params":{"name":"A21082622260821.jpg"}},"content-disposition":{"value":"attachment","params":{"filename":"A21082622260821.jpg"}},"content-transfer-encoding":"Base64"},"checksum":"8548ff1f9336a27aa0af659f22fb69f1","size":308784}],"_msgid":"4f5564e30b095b3c"}
once I manage to extract the image, what I try to do is send the notification with the attached image from the email to my telegram chat
can you help me?
Clarifications:
1. Sorry for my "English" is very bad, I know.
2. I accept proposals to optimize my flow if you are interested.
3. Please help me extract those images that are attached to the email.