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:
- Printing the message body only.
- Printing the message body and headers.
- Printing an HTML body.
- Setting the page layout.
- Auto-fit a TIFF to the printer.
- 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
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:
|FormattingFlags||Show or hide message details.||None |
|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 |
|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
Adjust Target DPI for Output TIFF
The following code snippet shows you how to use DPI for Output TIFF.