Making Outlook Talk To Perl: Part Three: Unexpected Gotcha |
|
March 23, 2008 |
I thought I’d finished discussing making Outlook talk to Perl, but then I remembered that some of the job files I get don’t have attachments, so I needed to add another bit which would copy the text of the message into the directory:
as before, but if no attachments, make a text file and save it there.
“, $text_fileor err (”Can’t open text file for output: $!”, 1); # I don’t know why the following is necessary: Perl seems to be # doing some kind of extra work on the message’s body. binmode $text_out, “:raw”; my $body = $message->Body; print $text_out $body; close $text_outor err (”Can’t close $text_file: $!”, 1);}
The gotcha here was that I had to set binmode $text_out, ":raw";. Not doing that resulted in a Unix-encoded file, so under Windows it showed up with lots of bogus ^M characters.
My question is, why is this necessary at all? I don’t see why Perl thought it was going to output a Unix file. Or did the Unix-style encoding of the text actually come from Outlook?



March 23, 2008
Leave a Reply