Xojo at the rescue
Today I once again got a winmail.dat from a Windows Outlook user. None of my unarchiver tool can read that. I dropped it on a text editor and saw it has an uncompressed PDF inside. So I quickly wrote this little Xojo app to extract it:// pick the winmail file
dim f as FolderItem = SpecialFolder.Desktop.Child("winmail.dat")
// read it to memory
dim b as BinaryStream = BinaryStream.Open(f)
dim s as string = b.Read(b.Length)
// as I know it has a PDF, we look for typical header/footer
dim p1 as integer = instrb(s, "%PDF-1")
if p1 > 0 then
dim p2 as integer = instrb(s, "%%EOF")
if p2 > 0 then
p2 = p2 + 5
// extract PDF portion
dim PDFData as string = midb(s, p1, p2-p1)
// write to file
dim o as FolderItem = SpecialFolder.Desktop.Child("winmail.pdf")
b = BinaryStream.Create(o, true)
b.Write PDFData
end if
end if
That is why I love Xojo so much. I just fire up the IDE, type 10 lines and a little problem is solved. Others may write a shell script, a php script or whatever to do the same. But I know Xojo well and so I prefer writing it in Xojo.