1月
15
2009

winmail.datがウザい件

Outlook 2007(X-Mailer: Microsoft Office Outlook 12.0)とかを使っている人から,winmail.datとかいう謎の添付ファイルがついたファイルが届きませんか?

winmail.datはMicrosoftの独自仕様のリッチテキストデータですが,メールはMIMEマルチパート形式になっていてプレインテキストもついてくるので何とか中身を読むことは可能です

ただ,添付ファイルがwinmail.datにまとめられてしまって,Outlook以外のメーラーでは開けないというクソ仕様です
しかもデフォルトでそういう設定になっている?ようで,HTMLメールの数倍ウザい存在です

Winowsではfentun.exe,MacだとTNEF’s Enoughなどの解凍ツールが有名ですが,ファイル名に漢字などのマルチバイト文字が含まれているとうまく解凍できないようです
これまでだとここであきらめて送り直してもらっていたのですが,筑波大学の新城氏が書かれたwinmail.rbというスクリプトを見つけました
このスクリプトは漢字OKで,先頭の設定を適当に修正することで,EUCな環境にも対応できるとのことです
RubyなのでOSを選ばないのもGood

winmail.rbはRuby TNEF libraryを使用します
ダウンロードしてきて適当な場所において,winmail.rbのrequire文を適宜修正すればOKなのですが,29Jan2004版では下記のような警告がでます

/Volumes/Home/h2/bin/tnef.rb:498: warning: parenthesize argument(s) for future version
/Volumes/Home/h2/bin/tnef.rb:574: warning: parenthesize argument(s) for future version
/Volumes/Home/h2/bin/tnef.rb:575: warning: parenthesize argument(s) for future version
/Volumes/Home/h2/bin/tnef.rb:576: warning: parenthesize argument(s) for future version
/Volumes/Home/h2/bin/tnef.rb:579: warning: don't put space before argument parentheses

要するに括弧を付けておいたほうがよいとかスペースを入れるなって話なので,修正しておきましょう

498c498
< debug sprintf '## Unknown attribute name %4.4x',attribute.name
---
> debug sprintf('## Unknown attribute name %4.4x',attribute.name)
574,576c574,576
< debug sprintf '## Unknown MAPI type 0x%4.4x',attr_type
< debug sprintf "attr_type: 0x%4.4x",attr_type
< debug sprintf "attr_name: 0x%4.4x",attr_name
---
> debug sprintf('## Unknown MAPI type 0x%4.4x',attr_type)
> debug sprintf("attr_type: 0x%4.4x",attr_type)
> debug sprintf("attr_name: 0x%4.4x",attr_name)
579c579
< attr = TNEFMAPI_Attribute.new ( attr_type, attr_name, attr_data)
---
> attr = TNEFMAPI_Attribute.new( attr_type, attr_name, attr_data)

パスの通った場所において,chmod a+xとかしとけば,

$ winmail.rb winmail.dat ls
$ winmail.rb winmail.dat extract

するだけでOKです

TNEFなんてさっさと消えてくれればいいんですが・・・

Written by h2 in: PC | タグ:

コメントはまだありません »

RSS feed for comments on this post. TrackBack URL

コメントをどうぞ

TheBuckmaker WordPress Themes Webhosting, MP3, AAC & Co