Fix for Outlook quoting (was Re: AARRRRGH!!! (was RE: Linux Install error)

Kevin D. Clark kclark at CetaceanNetworks.com
Fri Dec 19 10:30:58 EST 2003


Jeff Kinz writes:

> GOOD NEWS- There is a fix for Outlook that sets Outlook up to respond
> to emails in the normally accepted fashion:

Of course, these solutions depend on the benevolence of the people who
actually use these mailers.

OTOH, a while ago I wrote a quick hack that I use to transform
Outlook's broken quoting style into something reasonable.  This is
attached.  I use this program when I have to jump into a thread [1]
that is already being conducted using this broken quoting style.  I
hope that other people find it to be useful as well.

Regards,

--kevin

[1]  Most versions of Outlook don't seem to handle threading either,
     which in a twisted sort of way, seems to justify this broken
     quoting style.

-- 
Kevin D. Clark / Cetacean Networks / Portsmouth, N.H. (USA)
cetaceannetworks.com!kclark (GnuPG ID: B280F24E)
alumni.unh.edu!kdc




#!/usr/bin/perl

# fix-outlook-quoting.pl

# Author:  Kevin D. Clark (alumni.unh.edu!kdc)


# This program will take a region of text that looks like this....:

# > Kevin ,
# >
# > Blah blah blah blah blah bla.
# >
# > Ralph
# > 
# > 		 -----Original Message-----
# > 		From: 	Clark, Kevin
# > 		Sent:	Thursday, January 03, 2002 8:18 AM
# > 		To:	A bunch of people
# > 		Cc:	A bunch of other people
# > 		Subject: life, the universe, and everything
# > 
# > 		Ralph,
# > 
# >     Mumble mumble mumble mumble.
# > 
# > 		Kevin

# (you'd end up with such a region of text if your mail program quoted 
#  email in the cannonical way, and you had to deal with brain-dead
#  email clients like Outlook)

# ....and transforms this into this:

# > Clark, Kevin writes:
# > > Ralph,
# > > 
# > > Mumble mumble mumble mumble.
# > > 
# > > Kevin
# 
# > Kevin ,
# >
# > Blah blah blah blah blah bla.
# >
# > Ralph
# > 
# `


# this program is also general enough to handle a whole thread of the 
# braindead outlook quoting style.  After this transmogification is performed,
# it's simple enough to edit the resulting text to actually look decent.


# If you use emacs as your editor and you've yanked the mangled message into
# your reply buffer, some variant of:
#
#   C-u M-| fix-outlook-quoting.pl
#
# will suffice.

# If you use vi as your editor, some variant of:
#
# ma  (move to end of mangled text)
# :'a,.!fix-outlook-quoting.pl
#
# might work.



# Version history:
#
# 0.1 - initial version
# 0.2 - renamed original identifiers to be less offensive


undef $/;

$_ = <>;

($firstPart, $screwed) = /(.*?)(>\s*---*Original Message---*.*)/s;

# print ":$firstPart:\n";

$screwed =~ s/^[> \t]*//mg;

@screwedList = split(/---*Original Message---*/, $screwed);

# the first item in the list is screwed, er, I mean, blank...
shift @screwedList;


$i = 1;
for $f (@screwedList) {

  ($from) = $f =~ /From:\s+(.*?)\s*$/m;

  print "> " x $i++;
  print "$from writes:\n";
}

$i = scalar(@screwedList) + 1;
for $f (reverse(@screwedList)) {

  # delete first "paragraph" of screwed "headers"
  $f =~ s/.*?\n\s*\n//s;

  # quote properly
  $quotes = "> " x $i--;

  $f =~ s/^/${quotes}/mg;

  print "$f\n";
}

print "$firstPart\n";





More information about the Discuss mailing list