# Typesetting email with internet-style quoting using LaTeX?

I'm wandering if there exists a package, that would take so-called Internet-Style Quoted plain text of an email, and format it accordingly for a PDF output. Internet-style quoting is discussed on the Wikipedia page Posting style; so let's say I take an example from there, and I have the following to be the content of email.eml file:

At 10.01am Wednesday, Danny wrote:
> At 9.40am Wednesday, Jim wrote:
>> I'm going to suspend the mail service for approx. thirty
>> minutes tonight, starting at 5pm, to install some updates
>> and important fixes.

> Whoa!  Hold on.  I have a job scheduled at 5:30 which mails out
> a report to key tech staff.  Could you push it back an hour?
>
> By the way, which systems will be updated? I had some network
> problems after last week's update.  Will I have to reboot?

No problems. 6pm it is then.

Basically, I will update our WWW server and firewall.
No, you won't have to reboot.


Then, I'd imagine one could prepare something like an email.tex, which I could use to obtain a formatted PDF:

\documentclass{article}
\usepackage{???}

\begin{document}

\begin{QUOTEDEMAIL}
\input{email.eml}
\end{QUOTEDEMAIL}

\end{document}


I would be hoping that I'd at least have the control of choosing the color (grayscale) for the different levels of quoted replies (lines prefixed with '>')... But, if I can also control, say, fonts - or rendering lines instead of the '>' (like what Thunderbird does), that would be awesome! :)

Well, does anything similar to this exist?

-
I can smell the sweet \tikzmark solution of @PeterGrill :-) –  percusse Mar 27 '12 at 6:07
Hi @percusse - wish I knew what that sweet solution is :) Cheers! –  sdaau Mar 27 '12 at 6:09
If the desired solution was to have vertical lines to delineate the separate nesting depth, than perhaps \tikzmark would be useful but that would require editing the email text. So if it was to be used just a few times that would work. But, if you want to simply incorporate an existing email from an external file and not have to edit it, then listings is probably the way to go. –  Peter Grill Mar 27 '12 at 14:52
@sdaau: If you are curious about \tikzmark have a look at How to draw arrows between parts of an equation to show the Math Distributive Property (Multiplication)?, or Draw a line through one column of a matrix –  Peter Grill Mar 27 '12 at 14:53
Thanks for the comments, @PeterGrill - I indeed wanted to include an external file without further editing, so I concur about listings. However, many thanks for the \tikzmark links - those certainly point to a way of how a graphical solution (with vertical lines) would work. Cheers! –  sdaau Mar 28 '12 at 4:40

This is only a partial solution, but it would be the way to go - using listings:

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\begin{document}
Here is the message:

\lstset{
basicstyle=\ttfamily\small,
morecomment=[l][\color{red!50}]{>>\ },
morecomment=[l][\color{green!80}]{>\ },
}

\lstinputlisting{email.eml}
\end{document}


Formatting of the respective reply-levels is done via morecomments, actually specifying that line of "code" to be a "comment". listings fails to pick up the empty line in the above example, but correctly interprets if you don't mind level-specific formatting using just

\lstset{
basicstyle=\ttfamily\small,
morecomment=[l][\color{red!50}]{>},
}


say. Note that using > elsewhere in the email might cause problems.

-
Many thanks for the answer, @Werner - that looks pretty good, so accepting it for now... Cheers! –  sdaau Mar 27 '12 at 8:08