node-imap
node-imap copied to clipboard
get wrong struct with recursive attachment
I got the structure like this, there are two part id 2. The correct id would be 2 and 2.1. My attachment is an eml file including an pdf attachment inside, and the content type inside eml file is directly application/pdf.
[
{
type: 'mixed',
params: { boundary: '--_NmP-54c1758dc47913d1-Part_1' },
disposition: null,
language: null,
location: null,
},
[
{
partID: '1',
type: 'text',
subtype: 'html',
params: { charset: 'utf-8' },
id: null,
description: null,
encoding: '7bit',
size: 11,
lines: 0,
md5: null,
disposition: null,
language: null,
location: null,
},
],
[
{
partID: '2',
type: 'message',
subtype: 'rfc822',
params: { name: 'attachment.eml' },
id: null,
description: null,
encoding: '7bit',
size: 25843,
body: [
{
partID: '2',
type: 'application',
subtype: 'pdf',
params: { name: '20200910.pdf' },
id: null,
description: '20200910',
encoding: 'base64',
size: 18944,
md5: null,
disposition: null,
language: null,
location: null,
},
],
lines: 340,
md5: null,
disposition: { type: 'attachment', params: [Object] },
language: null,
location: null,
},
]
Could you set debug: console.log
in your connection config object and show the relevant lines resulting from the fetch?
Here is, i have already remove important information.
=> 'A28 UID FETCH 11 (MODSEQ UID FLAGS INTERNALDATE BODYSTRUCTURE BODY.PEEK[HEADER])'
<= '* 7 FETCH (UID 11 MODSEQ (30) FLAGS (\\Seen $HasAttachment) INTERNALDATE "09-Sep-2020 17:43:45 +0800" BODYSTRUCTURE (((("text" "plain" ("charset" "UTF-8") NIL NIL "base64" 426 5 NIL NIL NIL NIL)("text" "html" ("charset" "UTF-8") NIL NIL "quoted-printable" 1851 24 NIL NIL NIL NIL) "alternative" ("boundary" "000000000000e0547305aede4ba3") NIL NIL NIL)("image" "png" ("name" "image.png") "<ii_kev6yaxp0>" NIL "base64" 125082 NIL ("inline" ("filename" "image.png")) NIL NIL) "related" ("boundary" "000000000000e0547405aede4ba4") NIL NIL NIL)("message" "rfc822" ("name" "1.eml") "<f_kev6yzij3>" NIL "7bit" 25843 ("Sat, 5 Sep 2020 09:54:46 +0200 (CET)" "20200910" ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "to" "test.com")) NIL NIL NIL "<messageId>") ("application" "pdf" ("name" "20200910.pdf") NIL "20200910" "base64" 18944 NIL NIL NIL NIL) 340 NIL ("attachment" ("filename" "1.eml")) NIL NIL)("message" "rfc822" ("name" "2.eml") "<f_kev6yzin4>" NIL "7bit" 42151 ("Sat, 5 Sep 2020 09:54:45 +0200 (CET)" "20200910" ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "to" "test.com")) NIL NIL NIL "<messageId>") ("application" "pdf" ("name" "20200910.pdf") NIL "20200910" "base64" 35258 NIL NIL NIL NIL) 549 NIL ("attachment" ("filename" "2.eml")) NIL NIL) "mixed" ("boundary" "000000000000e0547505aede4ba5") NIL NIL NIL) BODY[HEADER] {2222}'
<= '* 7 FETCH (UID 11 MODSEQ (30) FLAGS (\\Seen $HasAttachment) INTERNALDATE "09-Sep-2020 17:43:45 +0800" BODYSTRUCTURE (((("text" "plain" ("charset" "UTF-8") NIL NIL "base64" 426 5 NIL NIL NIL NIL)("text" "html" ("charset" "UTF-8") NIL NIL "quoted-printable" 1851 24 NIL NIL NIL NIL) "alternative" ("boundary" "000000000000e0547305aede4ba3") NIL NIL NIL)("image" "png" ("name" "image.png") "<ii_kev6yaxp0>" NIL "base64" 125082 NIL ("inline" ("filename" "image.png")) NIL NIL) "related" ("boundary" "000000000000e0547405aede4ba4") NIL NIL NIL)("message" "rfc822" ("name" "1.eml") "<f_kev6yzij3>" NIL "7bit" 25843 ("Sat, 5 Sep 2020 09:54:46 +0200 (CET)" "20200910" ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "to" "test.com")) NIL NIL NIL "<messageId>") ("application" "pdf" ("name" "20200910.pdf") NIL "20200910" "base64" 18944 NIL NIL NIL NIL) 340 NIL ("attachment" ("filename" "1.eml")) NIL NIL)("message" "rfc822" ("name" "2.eml") "<f_kev6yzin4>" NIL "7bit" 42151 ("Sat, 5 Sep 2020 09:54:45 +0200 (CET)" "20200910" ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "from" "test.com")) ((NIL NIL "to" "test.com")) NIL NIL NIL "<messageId>") ("application" "pdf" ("name" "20200910.pdf") NIL "20200910" "base64" 35258 NIL NIL NIL NIL) 549 NIL ("attachment" ("filename" "2.eml")) NIL NIL) "mixed" ("boundary" "000000000000e0547505aede4ba5") NIL NIL NIL) )'
@chenxiaoba did you find any solution?? I am facing same issue.
@chenxiaoba did you find any solution?? I am facing same issue.
@pratibhaSingh17
I correct it by myself, If the struct is an attachment and its part id same as the mail, then append ".1" to attachment part id.