Html Text Previewer Class
A text previewer for HTML content.
Definition
Namespace: MimeKit.Text
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public class HtmlTextPreviewer : TextPreviewer- Inheritance
- Object TextPreviewer HtmlTextPreviewer
Remarks
A text previewer for HTML content.
Example
C#
public static string GetPreviewText (MimeMessage message)
{
// TextPreviewer.GetPreviewText() picks the appropriate previewer (PlainTextPreviewer or
// HtmlTextPreviewer) based on the format of the text part and returns a short, single-line
// snippet of the text which is useful for displaying in a message list.
var body = message.BodyParts.OfType<TextPart> ().FirstOrDefault (x => !x.IsAttachment);
if (body == null)
return string.Empty;
if (body.IsHtml) {
// The previewers can also be used directly in order to customize the length.
var previewer = new HtmlTextPreviewer { MaximumPreviewLength = 100 };
return previewer.GetPreviewText (body.Text);
}
return TextPreviewer.GetPreviewText (body);
}
Constructors
| HtmlTextPreviewer | Initialize a new instance of the HtmlTextPreviewer class. |
Properties
| InputFormat |
Get the input format.
(Overrides TextPreviewerInputFormat) |
| MaximumPreviewLength |
Get or set the maximum text preview length.
(Inherited from TextPreviewer) |
Methods
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object) |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object) |
| GetHashCode | Serves as the default hash function. (Inherited from Object) |
| GetPreviewText(String) |
Get a text preview of a string of text.
(Inherited from TextPreviewer) |
| GetPreviewText(TextReader) |
Get a text preview of a stream of text.
(Overrides TextPreviewerGetPreviewText(TextReader)) |
| GetPreviewText(Stream, String) |
Get a text preview of a stream of text in the specified charset.
(Inherited from TextPreviewer) |
| GetPreviewText(Stream, Encoding) |
Get a text preview of a stream of text in the specified encoding.
(Inherited from TextPreviewer) |
| GetType | Gets the Type of the current instance. (Inherited from Object) |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object) |
| ToString | Returns a string that represents the current object. (Inherited from Object) |