Yeraze / ytnef

Yeraze's TNEF Stream Reader - for winmail.dat files
GNU General Public License v2.0
32 stars 22 forks source link

HTML & Text message parts #82

Open amit777 opened 4 years ago

amit777 commented 4 years ago

Hi, I've been experimenting with this tool and comparing it to the regular tnef tool on linux. I noticed that the regular tnef tool is able to extract the HTML and TEXT parts of a winmail.dat message (along with RTF if it's there). Is it possible to do the same with this lib?

Yeraze commented 4 years ago

I'm sure it can... Can you provide a sample file for testing?

amit777 commented 4 years ago

Sure, I'm going to do a couple more tests and compile the results and send them to you. Is it ok if I email you some of the test files since they have some semi-private data in them?

Yeraze commented 4 years ago

Sure, that's fine.

amit777 commented 4 years ago

Actually, I just noticed ytnefprint does seem to find the field and the data in that field looks correct:

 #1: Type: [ BINARY  ]  Code: [PR_BODY_HTML]
    Size: 487    Value: [<html>..<head>..<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">..<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>..</head>..<body dir="ltr">..<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">..<span style="font-family: Calibri, Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">[[#]]</span><br>..</div>..</body>..</html>..]

So, I guess my next question is does the ytnef binary allow exporting that as message.html or something similar?

amit777 commented 4 years ago

Ahh, I see in the ytnef/main.c the saveRTF flag.. looks like there needs to be another flag for the HTML body. I'm going to continue playing around with this. If I find any TNEF's that don't parse correctly, will send it over to you. I feel like I found one that was causing a seg fault yesterday..

amit777 commented 4 years ago

I was working on creating a pull request for a couple enhancements. But I was hoping you could clarify this part of the lib/ytnef.h code:

#define attAttachData               ATT( atpByte,       0x800F) /* PR_ATTACH_DATA_xxx */
#define attAttachTitle              ATT( atpString,     0x8010) /* PR_ATTACH_FILENAME */
#define attAttachMetaFile           ATT( atpByte,       0x8011) /* PR_ATTACH_RENDERING */

Where do the 0x800F, 0x8010 and 0x8011 come from? Are they defined in some standard somewhere?

Yeraze commented 4 years ago

Not really, TNEF (afaik) is something Microsoft made up.. You'll find lots of references to it in the Public Microsoft documentation like this : https://docs.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessageflags-canonical-property

amit777 commented 4 years ago

I created a pull request for the HTML body export as well as some additional header defs. https://github.com/Yeraze/ytnef/pull/83

Hopefully it fits your desired coding style! Thanks again for creating this awesome lib.