Aspose.Email.Printing Features

Printing Features

The Aspose.Email.Printing namespace provides a rich set of features for printing mail messages to different formats (XPS or TIFF) and configuring page layouts. This article describes them. There are several options for how an email message can be printed from Aspose.Email:

  1. Printing the message body only.
  2. Printing the message body and headers.
  3. Printing an HTML body.
  4. Setting the page layout.
  5. Auto-fit a TIFF to the printer.
  6. Adjust Target DPI for output TIFF.

Printing the Message Body

The following code snippet shows you how to creates a message and prints it without headers first to an XPS file and then to a TIFF file.

Printing Message Headers and Body

The following code snippet shows you how to display the headers and print them as well as the message body, change the FormattingFlags to MailInfo.

Printing Message with HTML Body

Messages with an HTML body can also be printed. The following code snippet shows you how to print a message with HTML Body.

Setting Page Layout for Printing

Aspose.Email.Printing.MailPrinter provides controls for setting the following properties of the page layout:

Property Description Default Value
FormattingFlags Show or hide message details. None [1]
MarginTop Get or set the top margin. 0.5
MarginLeft Get or set the left margin. 0.5
MarginBottom Get or set the bottom margin. 0.5
MarginRight Get or set the right margin. 0.5
PageUnit Get or set measurement units. Inch [2]
PageHeight Get or set the page height. 11.69
PageWidth Get or set the page width. 8.27
  • There are two flags: MailInfo and None
  • Page units can be one of Inch, Pixel, Point, Cm, or Millimeter.

The code snippet that follows uses arbitrary settings to illustrate how these properties are used. It sets up a page 20 cm high and 8 cm wide, with 2 cm margins.

Auto-fit a TIFF

Aspose.Email.Printing provides the MessageFormattingFlags.AutoFitWidth property which allows you to auto-fit the TIFF to the printer. The following code snippet shows you how to use Auto-fit.

Adjust Target DPI for Output TIFF

The following code snippet shows you how to use DPI for Output TIFF.