koodaamo / tnefparse

a TNEF decoding library written in python, without external dependencies
GNU Lesser General Public License v3.0
49 stars 37 forks source link

How to recognise inline attachment #70

Closed Sam-Gracy closed 4 years ago

Sam-Gracy commented 4 years ago

Hi,

Using this library I am able to extract all the attachments from winmail.dat. I have a challenge to differentiate inline attachments (Inline attachment usually is an attachment that we can see directly within the email message body ) and normal attachments.

Is there a way that I can recognize the inline attachments? Could you please help me with that

Many Thanks, Suresh.

jugmac00 commented 4 years ago

Hi Suresh,

while we both have to wait for @petri for a definitive answer, as far as I know, in "normal" HTML emails, the difference between inline and "attached" attachment is only a reference to the attachment in the HTML content.

So, if you have access to an example, you could open it with tnefparse and have a look at the body or htmlbody attributes and search for a reference of the attachments.

Offtopic @petri The only time I encounter winmail.dats is when the sender of an email or the admin of the sender's company presumably misconfigured Outlook or the Exchange server.

Is there a way or even a program to create winmail.dats on purpose? e.g. in order to create test cases for tnefparse.

I tried to produce such an email when using Outlook and setting format to rich text, but I could not force a winmail.dat - maybe the exchange server nowadays automatically fixes this.

petri commented 4 years ago

@Sam-Gracy to be honest, I have no idea except to echo what @jugmac00 already suggested. Perhaps https://stackoverflow.com/questions/30351465/html-email-with-inline-attachments-and-non-inline-attachments might help you out?

Re generating winmail.dat ... I thought that'd be the way, too, @jugmac00 ... when you tried, did you actually rich format some message text as well? Anyway, seems MS products have detailed heuristics on deciding the conversions: https://docs.microsoft.com/en-us/exchange/mail-flow/content-conversion/tnef-conversion?view=exchserver-2019

Sam-Gracy commented 4 years ago

Thank you so much for your suggestions @jugmac00 & @petri. I'll try the suggested scenarios and get back to you. So that it may be helpful for others.

Many Thanks, Suresh

Sam-Gracy commented 4 years ago

Hi @petri

Is there a way that I can get the content_id, content_disposition of the attachments that were extracted from winmail.dat? Like, we can get the attachment name a.name, is there a field where we have attachment content-id?

Could you please help me with this?

petri commented 4 years ago

Sorry, no. I have no idea. And if you have new, different questions, please open a new ticket rather than re-using another closed ticket.

Sam-Gracy commented 4 years ago

sure, thank you