Save Email Attachment with node-red-node-email

#1

Hello everybody,
can someone help me save my E-mail Attachment with node-red-node-email to process the files further? I'm new with Node Red.

Thanks

0 Likes

#2

attach a debug node to the email node and configure the debug to display everything not just msg.payload.

What do you see? Cut and paste the output here but remember to hide your email address after pasting

0 Likes

#3

{"payload":"\n__________\n\nMit freundlichen Grüßen\n\nxxx@xxxxx.com\n\nxx@xxxxxxxx.com\n\n","topic":"Test","date":"2019-02-13T13:10:39.000Z","header":{"x-envelope-from":"xxxxxxxxx@xxxxx.com","x-envelope-to":"123456@xxxxxxx.com","x-delivery-time":"1550063448","x-uid":"6","return-path":"xxxxxxxxx@xxxxxx.com","authentication-results":["strato.com; dmarc=pass (p=QUARANTINE sp=NONE) header.from=me.com","strato.com; arc=none","strato.com; dkim=pass header.d=me.com","strato.com; dkim-adsp=pass header.from="xxxxxxxxxxx@xxxxxx.com"","strato.com; spf=pass smtp.mailfrom="xxxxxxx@xxxxxxx.com""],"x-rzg-class-id":"mi07","x-rzg-expurgate":"suspect/normal","x-rzg-expurgate-id":"149500::1550063448-000006FF-1DFFF52E/23/3","x-strato-messagetype":"email","received-spf":"pass (strato.com: domain me.com designates 17.58.63.175 as permitted sender) mechanism=ip4; client-ip=17.58.63.175; helo="st43p00im-zteg10063401.me.com"; envelope-from="xxxxxxxxxx@xxxxxx.com"; receiver=smtpin.rzone.de; identity=mailfrom;","received":["from st43p00im-zteg10063401.me.com ([17.58.63.175]) by smtpin.rzone.de (RZmta 44.9 OK) with ESMTPS id K028f3v1DDAlzjC (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate) for 123456@xxxxxxxxx.com; Wed, 13 Feb 2019 14:10:47 +0100 (CET)","from xxxxxxxxxxxx (business-90-187-97-77.pool2.vodafone-ip.de [90.187.97.77]) by st43p00im-zteg10063401.me.com (Postfix) with ESMTPSA id 9B7668A0165 for 123456@xxxxxxxxxxxx.com; Wed, 13 Feb 2019 13:10:44 +0000 (UTC)"],"dkim-signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1550063445; bh=rj6yGpwaJUp9GvgX3pR1JuSlWKrGerxUg9UUPUiJNtI=; h=From:Content-Type:Mime-Version:Subject:Message-Id:Date:To; b=eYcRbvUKB2GgM93kIGgdGkeJqSi8MEW5kGYFoM5JS1Pnt3lYU4/zYyjGGV6Pj7WvI pFGiCWInMTyW7hS2lKhbKlFwBmKlHWjjreNXjmZHdm0wcdPJLCAHgf5WhfTdg1nyq7 VilvbI546r8hLr1lq0hFjbV7/ckaXWT2pKmAZPcnEsQ2RpTSTuL+uKn9SIJOUbd/f9 NzUN5IG256n/kR6z3T64qOoTHbJYKXq8aXmtsQ+Dh0VYoO5vcnC60ElBmiPu+BiqiA i90LPedO60z0TC4Ojpj3mNrRe+fdZu/WO5gQZd0/YJ1HgCzCFOfjqSfm7RA6GtVO3k kRiZxMHTMPC4Q==","from":"xxxxxxxxxx xxxxxxxxx@xxxxxx.com","x-mailbutler-message-id":"1B133D5B-300F-4E1E-A978-31D6688D6330","content-type":"multipart/alternative; boundary="Apple-Mail=E02985BF-9870-47A0-B37A-3D9B1BECCC01"","mime-version":"1.0 (Mac OS X Mail 12.2 \(3445.102.3\))","subject":"Test","message-id":"97413911-CF65-4743-BF14-14C635305C4D@me.com","date":"Wed, 13 Feb 2019 14:10:39 +0100","to":"123456@xxxxxxxx.com","x-mailer":"Apple Mail (2.3445.102.3)","x-proofpoint-virus-version":"vendor=fsecure engine=2.50.10434:,, definitions=2019-02-13_08:,, signatures=0","x-proofpoint-spam-details":"rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=313 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1812120000 definitions=main-1902130097"},"html":"<meta http-equiv="content-type" content="text/html; charset=utf-8" /><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
\n<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class="">\n<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
_________<br class=""><br class="">Mit freundlichen Grüßen<br class=""><br class="">xxxxxxxxxxxx<br class=""><br class=""><a href="mailto:xxxxxx@xxxxxxxxx.com" class="">xxxxx@xxxxxxxx.com<br class="">\n\n\n<br class=""><img src="https://bowtie.mailbutler.io/tracking/hit/c917cbaa-b9dd-4722-9a37-0089b2511d33/25cb81e4-614e-4f85-9db2-25501e177c1a/t.g...","from":"xxxxxxxxx@xxxx.com","attachments":[{"contentDisposition":"inline","fileName":"Web App Software.pdf","contentType":"application/pdf","transferEncoding":"base64","generatedFileName":"Web App Software.pdf","contentId":"5ab6933cc85d9607bebdceedccdb7314@mailparser","checksum":"1dd3417736b017e7840164402e806de5","length":201885,"content":[37,80,68,70,45,49,46,51,10,37,196,229,242,229,235,167,243,160,208,196,198,10,52,32,48,32,111,98,106,10,60,60,32,47,76,101,110,103,116,104,32,53,32,48,32,82,32,47,70,105,108,116,101,114,32,47,70,108,97,116,101,68,101,99,111,100,101,32,62,62,10,115,116,114,101,97,109,10,120,1,181,155,91,119,228,68,146,128,223,245,43,114,47,176,50,75,201,146,50,117,99,24,118,192,12,208,244,62,48,224,115,230,97,61,15,213,213,234,118,45,229,42,183,171,12,135,31,58,255,103,190,200,171,234,226,166,221,180,225,128,84,161,204,200,184,71,100,100,250,141,250,155,122,163,170,94,245,101,169,154,102,80,181,81,119,163,250,187,90,171,243,139,109,165,22,91,85,218,127,183,11,25,103,95,103,238,177,184,81,95,93,170,178,40,117,221,170,203,69,214,185,143,157,106,234,186,232,26,109,212,172,7,241,229,141,58,191,188,172,153,123,249,74,253,159,202,255,237,223,207,20,223,242,255,224,49,240,243,63,207,84,213,184,159,64,63,250,88,192,89,254,95,87,249,71,87,103,159,156,41,62,253,55,176,127,168,203,239,213,95,47,29,181,15,80,49,64,133,138,84,176,180,172,159,29,174,255,233,236,76,213,165,202,139,171,252,252,140,225,249,236,42,47,171,217,172,214,87,185,185,202,155,51,53,244,42,215,45,100,169,188,234,102,253,108,248,236,42,255,211,185,105,207,50,32,159,95,229,127,6,65,205,188,47,174,242,255,57,83,6,38,244,95,174,242,47,191,250,170,191,112,179,204,249,197,172,187,202,191,182,40,52,255,103,185,191,186,85,117,63,251,234,27,221,157,159,101,137,35,175,1,83,189,191,2,134,108,202,122,83,247,69,55,192,198,204,152,35,249,255,73,95,56,190,225,247,219,171,64,151,208,251,209,71,78,206,217,239,200,185,57,146,243,137,101,42,22,153,85,153,200,24,123,201,191,114,143,218,61,190,123,246,172,112,111,233,209,105,140,224,123,198,85,8,20,176,60,102,95,124,142,153,200,91,59,251,230,89,117,241,197,69,119,150,9,186,193,205,126,22,85,225,140,233,121,219,95,32,111,25,209,185,7,203,51,219,47,251,172,10,186,183,208,231,103,153,24,130,147,198,236,121,43,70,224,102,121,28,207,205,115,167,53,55,196,67,219,202,227,22,211,112,227,63,195,52,192,244,156,233,216,176,103,217,180,159,243,147,223,30,201,33,173,206,46,60,167,30,247,95,4,95,150,63,55,94,94,254,129,97,25,143,21,203,114,107,62,255,223,72,43,28,98,94,34,38,143,6,35,115,31,191,209,78,94,73,26,34,155,103,83,127,242,214,215,54,214,250,58,92,243,192,255,43,28,161,82,248,63,206,132,85,169,27,213,116,157,146,183,149,125,107,77,81,245,77,83,241,19,159,155,252,186,86,175,8,15,125,215,27,93,153,83,111,25,72,251,178,168,228,31,248,46,251,170,232,161,227,70,181,85,93,148,109,221,77,128,171,125,96,93,232,182,101,197,48,29,171,40,251,0,148,133,207,127,24,239,22,227,237,238,126,190,82,119,75,98,151,110,202,2,148,181,13,30,157,41,90,173,161,57,204,87,93,109,4,101,163,22,55,217,249,179,155,74,125,189,33,216,196,216,119,254,227,184,154,239,150,191,140,23,155,213,230,110,121,51,238,238,150,11,135,184,44,154,178,236,135,214,141,157,165,159,72,163,169,203,174,232,251,46,115,193,178,106,125,232,106,85,197,122,85,211,214,170,31,134,206,57,233,66,228,76,144,204,213,153,186,252,255,16,237,18,62,89,224,209,232,135,146,0,101,99,224,194,199,224,252,167,235,205,237,242,213,111,31,96,145,190,45,180,38,22,30,47,66,160,87,87,249,245,110,119,187,253,12,203,173,122,231,104,13,143,95,157,179,252,234,236,159,71,7,176,216,6,162,122,34,62,78,33,158,185,96,8,191,54,55,231,87,103,83,147,125,131,49,189,143,204,77,213,20,195,128,204,39,244,122,153,11,189,215,227,234,118,171,198,245,238,142,229,89,119,188,13,47,235,241,254,110,171,110,55,4,12,224,144,108,63,223,169,221,245,184,188,83,155,245,106,185,30,213,214,49,180,243,68,135,185,219,66,253,120,255,194,77,249,141,177,234,199,249,114,181,85,203,173,204,86,11,132,33,44,134,209,202,79,31,23,215]}],"_msgid":"fb2b2c01.5dd83"}

0 Likes

#4

when sharing code it’s useful to format it correctly.
It makes it easier to read.

But inside that you will see attachments (msg.attachments) that contains an array of the attachments.

If you know it’s always the first one you are interested in you can move it to mag.payload using a change node.
Then use the base64 node to decode it and the contents of the attachment will be available for the rest of your flow.

0 Likes

#5

I'm sorry and I will be better next time.

Please see the Screenshot. Is it right like this? I like to save the pdf Attachment.

0 Likes

#6

no as the email can contain more than one attachment. it is in an array (that’s what the [ ] signify)

You can use the debug panel to select the correct bit see the page in the documentation on “working with messages”
Javascript objects and arrays are key to working in node-red it is time well spent working through a tutorial online

0 Likes