MailBee.NET Objects 4.0

Element Constructor (String)

Initializes a new instance of Element object with the specified HTML markup.

public Element(
   string htmlText
);

Parameters

htmlText
The actual HTML markup of the Element.

Remarks

htmlText can contain any string including HTML with broken markup, plain text, etc. MailBee will attempt to parse it even if not all tags are closed, or some tags are closed incorrectly, etc.

Exceptions

Exception Type Condition
MailBeeInvalidArgumentException htmlText is a null reference (Nothing in Visual Basic).

Example

This samples initializes Element object with certain HTML markup and then displays the name of the root tag and the inner HTML contents of the specified markup.

[C#]
// To use the code below, import these namespaces at the top of your code.
using System;
using MailBee.Html;

// The actual code (put it into a method of your class).
Element richText = new Element("<html><head><title>Sample header</title></head><body>Short sample<body></html>");
Console.WriteLine("The root tag name is : " + richText.TagName);
Console.WriteLine("The inner HTML source is : " + richText.InnerHtml);
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee.Html

' The actual code (put it into a method of your class).
Dim richText As New Element("<html><head><title>Sample header</title></head><body>Short sample<body></html>")
Console.WriteLine("The root tag name is : " & richText.TagName)
Console.WriteLine("The inner HTML source is : " & richText.InnerHtml)

See Also

Element Class | MailBee.Html Namespace | Element Constructor Overload List