Hi Jaap, Here's the code that saves the attachment:

if ($code =~ /quoted-printable/i) { print "printing $num to c:\\$filename\n"; open(K, ">c:\\$filename"); binmode(K); #not sure when to use this, seems to be necessary for pd +f attachments print K MIME::QuotedPrint::decode_qp(join "", @{ $message->{body}->{ +data} }); close K; }

The error when trying to open the bad pdf is:
"The file is damaged and cannot be repaired."

Here's a snippet of a good one (note that in Notepad the
line-endings are little squares - \r I presume):

%PDF-1.2 %ßÜÂÞ - Business Objects 1 0 obj << /Type /Pages /Count 1 /Kids [ 4 0 R ] >> endobj 2 0 obj << /CreationDate (D:20030206205259Z) /ModDate (D:20030206205259Z)

And here's a bad one:

%PDF-1.2 %ßÜÂÞ - Business Objects 1 0 obj << /Type /Pages /Count 17 /Kids [ 4 0 R 5 0 R 6 0 R 7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 +R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R ] >> endobj 2 0 obj << /CreationDate (D:20030206205456Z) /ModDate (D:20030206205456Z)

Any advice would be great!


In reply to Re: Re: saving pdf attachments by busch4al
in thread saving pdf attachments by busch4al

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.