Want to print an HTML email

Posted on 2006-05-27
Last Modified: 2010-04-05
Having downloaded emails such as newletters or brochures (HTML, many pictures etc) I want to be able to print them out, but include some custom header information (our internal email number, who printed it etc).

Previuosly, I have used a TWebBrowser to load the file in, then print from there, not ideal as there is a lack of control and no option for header \ footer.
I have also converted the document into an image and printed from there - even less perfect.

I typically use QuickReport, so an answer involving that would be ideal.
If I have to buy a component in order to deal with this then I will.
Question by:Richard_Clayton
    LVL 5

    Accepted Solution

    LVL 6

    Assisted Solution

    Hello Sir,

       You can print a html file with certain modifications to it as follows.

    procedure printreport;
      //Copy and paste your html source code using and rewrite it as follows for eg
      Writeln(F,'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "">' );
      Writeln(F,' <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
      Writeln(F,'<title>Delphi Programming: Want to print an HTML email</title>');
      Writeln(F,'<link href="/images/ee.ico" rel="shortcut icon">');
      Writeln(F,'<link href="/scripts/ee_cd11083aff598d3b113980a519d4b987.css" rel="stylesheet" type="text/css">
      Writeln(F,'<script src="/scripts/eeSubs_88fcb4c868a5c02661171720cf388b79.js" type="text/javascript"></script>
    Writeln(F,'<meta name="description" content="Having downloaded emails such as newletters or brochures (HTML, many pictures etc) I want to be able to print them out, but include some custom header information (our internal email number, who...">');

    with regards,
    LVL 26

    Assisted Solution

    You could use an IHTMLDocument2 instance to load the file into, then take the document's
    body and assign it to a TWebBrowser and modify the HTML to include the header info you
    require and then just use the ExecWB way of printing them using the TWebBrower.

    If you'd like a sample, I can show you.
    LVL 6

    Expert Comment

    Hello Sir,

      Kindly let us know whether the sample works fine.

    with regards,

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now