Open shivamjain1210 opened 6 years ago
It's not clear what you mean/what you're asking. imap
does not parse attachments. The only public general parser included in this module is an email header parser (Imap.parseHeader()
), there is nothing to parse/decode bodies of emails or attachments. You will need to do that yourself, possibly with the help of some modules on npm, depending on your needs.
Sorry I didn't clear my question. Actually my question was - how to fetch/read the attachment(which is email itself), as currently this type of email attachment is not getting read correctly, unlike the normal email body which is getting read properly.
You will need to fetch the message's structure first to get the attachment's partID
, which you can then pass to fetch()
as part of the bodies
option. You can see example structure objects and how to fetch them in the readme.
I am following the above procedure, it works fine for all the email parts (body, pdf attachment) except the email attachment, as this is coming as string(that too in encoded form) as shown in the below example :
Content-Language: en-029 X-MS-Exchange-Organization-AuthSource: APPS0166s.fbr.com X-MS-Has-Attach: yes X-Auto-Response-Suppress: DR, OOF, AutoReply X-MS-Exchange-Organization-SenderIdResult: Pass X-MS-Exchange-Organization-PRD: brileyfbr.com X-MS-TNEF-Correlator: received-spf: Pass (APPS0166s.fbr.com: domain of DailyAlert@brileyfbr.com designates 148.163.157.60 as permitted sender) receiver=APPS0166s.fbr.com; client-ip=148.163.157.60; helo=mx0a-001db101.pphosted.com; Content-Type: multipart/related; boundary="_00710591391421054761523352499075JavaMailapachejvm301intblu"; type="multipart/alternative" MIME-Version: 1.0
--_00710591391421054761523352499075JavaMailapachejvm301intblu Content-Type: multipart/alternative; boundary="_00010591391421054761523352499075JavaMailapachejvm301intblu"
--_00010591391421054761523352499075JavaMailapachejvm301intblu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64
DQoNCiAgICAgICAgREFJTFkgQUxFUlQNCkFwcmlsIDEwLCAyMDE4DQoNCldoYXQncyBDaGFuZ2Vk Pw0KVGlja2VyICBMYXN0IENsb3NlIFByaWNlKiAgICAgICBPcGluaW9uIFByaWNlIFRhcmdldCAg ICBFYXJuaW5ncyBDdXJyZW50IEZZICAgICBFYXJuaW5ncw0KTmV4dCBGWSBFc3QuDQpUeXBlDQpG cm9tICAgIFRvICAgICAgRnJvbSAgICBUbyAgICAgIEZyb20gICAgVG8gICAgICBGcm9tICAgIFRv
If the multipart/alternative's part information is not available in the nested structure object (usually it is), then you will need to use a separate email parser as this module does not expose such functionality and does not parse any attachments (multipart or otherwise).
I am getting emails with attachments in the form of email. Is there any way to parse this attachment part correctly, as with current IMAP code this email attachment(encoded as 7BIT) is not getting regenerated as the actual email in html form.