[Mimedefang] Code to remove winmail.dat files and replace them with the attachments.

Thomas Tinglum ttinglum at norway.atmel.com
Thu Jul 21 04:43:56 EDT 2005


Hi

First I had troubles compiling ytnef into my freebsd system, switching 
to the tnef package supplied in freebsd' ports didnt do the trick 
either. It was then I replied to your post  :)

Fiddeling around I found that tnef dont return the actual files, or at 
least I have'nt gotten it to, as ytnef does.
@new_files = `/usr/local/bin/tnef -f Work $path`; will therfore fail.

So the soution:
Using Rached Blili's tnefclean.pl script as a reference I hacked 
together a mimedefang filter which uses tnef instead of ytnef.

The logic is as follows.
Use tnef to extract the filenames and put them in an array.
Use tnef to extract the files into a tmpdir.
Merge the patch to the tmpdir with the filenames into an array and you 
have a full path to the extracted files.

*Note* I guess this is somewhat nasty since I let the script deal with 
the full path to the files instead of separation the path and filename. 
It shows up in i.e pine where the filename is presented with the full 
path as its name. How

Supply this array to the functions in the patch. Should work fine.
This is actually all that is required, and it works very well according 
to my needs.

 I also added some cleanup at the end, removing the 
"X-MS-TNEF-Correlator" header, adding a new one and deleting the tmp 
directory.

Please note that:
This was my very first encounter with perl scripting and I guess there 
are several better solutions to this problem. The reason for wanting to 
kill the winmail.dat attachments is because we have a mix of outlook and 
thunderbird users. I know very well that the tnef problem should be 
dealt with clientside, but that is not an accepted solution for me.
The only problem we have with tnef mail is when outlook sends a rft 
coded mail, there are no exchange server involved, so this is purely a 
client to client problem.

Hope this helps somenoe else wanting to do this serverside :)

regards
 Thomas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ttinglum.vcf
Type: text/x-vcard
Size: 182 bytes
Desc: not available
URL: <https://lists.mimedefang.org/pipermail/mimedefang_lists.mimedefang.org/attachments/20050721/79fed91c/attachment.vcf>


More information about the MIMEDefang mailing list