HtmlForgeX

API Reference

Class

EmailText

Namespace HtmlForgeX.Email
Assembly HtmlForgeX.Email
Base Element
Implements
ILayoutAware ITextElement<EmailText>

Represents a text element for email layouts with email-safe styling. Paragraphs use ParagraphMargin when stacked and when transitioning to other components.

Inheritance

Constructors

EmailText 2 overloads
public EmailText() #

Initializes a new instance of the EmailText class.

public EmailText(String content) #

Initializes a new instance of the EmailText class with content.

Parameters

content System.String requiredposition: 0
The text content.

Methods

AddText 2 overloads
public EmailText AddText(String text) #
Returns: EmailText

Adds a text line to the element.

Parameters

text System.String requiredposition: 0
The text line to add.

Returns

The EmailText instance.

public EmailText AddText(params String[] textLines) #
Returns: EmailText

Adds multiple text lines to the element.

Parameters

textLines System.String[] requiredposition: 0
The text lines to add.

Returns

The EmailText instance.

public EmailText AppendContent(String content) #
Returns: EmailText

Appends content to the existing text.

Parameters

content System.String requiredposition: 0
The content to append.

Returns

The EmailText object, allowing for method chaining.

IsInContainer() #

Checks if this EmailText is being rendered inside an EmailBox or similar container.

Returns

True if inside a container that handles table structure, false otherwise.

IsInEmailColumn() #

Checks if this EmailText is being rendered inside an EmailColumn.

Returns

True if inside an EmailColumn, false otherwise.

public EmailText Text(String content) #
Returns: EmailText

Sets the text content.

Parameters

content System.String requiredposition: 0
The text content.

Returns

The EmailText object, allowing for method chaining.

public override String ToString() #
Returns: String

Converts the EmailText to its HTML representation.

Returns

HTML string representing the email text.

public EmailText WithAggressiveWrapping() #
Returns: EmailText

Sets aggressive text wrapping - breaks anywhere to fit narrow spaces. Useful for very narrow columns or mobile layouts.

Returns

The EmailText object, allowing for method chaining.

public virtual EmailText WithAlignment(Alignment alignment) #
Returns: EmailText

Sets the text alignment.

Parameters

alignment HtmlForgeX.Email.Alignment requiredposition: 0
The alignment option.

Returns

The EmailText instance.

WithBackground 2 overloads
public EmailText WithBackground(RGBColor color) #
Returns: EmailText

Sets the background color.

Parameters

color System.String requiredposition: 0
The background color.

Returns

The EmailText object, allowing for method chaining.

WithBackground(HtmlForgeX.Email.RGBColor color) #

Sets the background color using RGBColor.

Parameters

color HtmlForgeX.Email.RGBColor required
The background color.

Returns

The EmailText object, allowing for method chaining.

WithColor 2 overloads
public virtual EmailText WithColor(RGBColor color) #
Returns: EmailText

Sets the text color.

Parameters

color System.String requiredposition: 0
The text color.

Returns

The EmailText object, allowing for method chaining.

WithColor(HtmlForgeX.Email.RGBColor color) #

Sets the text color using RGBColor.

Parameters

color HtmlForgeX.Email.RGBColor required
The text color.

Returns

The EmailText object, allowing for method chaining.

public virtual EmailText WithFontFamily(String fontFamily) #
Returns: EmailText

Sets the font family.

Parameters

fontFamily System.String requiredposition: 0
The font family.

Returns

The EmailText object, allowing for method chaining.

WithFontSize 2 overloads
public virtual EmailText WithFontSize(EmailFontSize fontSize) #
Returns: EmailText

Sets the font size.

Parameters

fontSize System.String requiredposition: 0
The font size.

Returns

The EmailText object, allowing for method chaining.

WithFontSize(HtmlForgeX.Email.EmailFontSize fontSize) #

Sets the font size using predefined values.

Parameters

fontSize HtmlForgeX.Email.EmailFontSize required
The predefined font size.

Returns

The EmailText object, allowing for method chaining.

WithFontWeight 2 overloads
public virtual EmailText WithFontWeight(FontWeight fontWeight) #
Returns: EmailText

Sets the font weight.

Parameters

fontWeight System.String requiredposition: 0
The font weight.

Returns

The EmailText object, allowing for method chaining.

WithFontWeight(HtmlForgeX.Email.FontWeight fontWeight) #

Sets the font weight using predefined values.

Parameters

fontWeight HtmlForgeX.Email.FontWeight required
The predefined font weight.

Returns

The EmailText object, allowing for method chaining.

public EmailText WithLineBreak() #
Returns: EmailText

Enables line break after this text.

Returns

The EmailText object, allowing for method chaining.

public virtual EmailText WithLineHeight(String lineHeight) #
Returns: EmailText

Sets the line height.

Parameters

lineHeight System.String requiredposition: 0
The line height.

Returns

The EmailText object, allowing for method chaining.

WithMargin 3 overloads
WithMargin(HtmlForgeX.Email.EmailSpacing spacing) #

Sets the margin using predefined spacing values.

Parameters

spacing HtmlForgeX.Email.EmailSpacing required
The predefined spacing value for all sides.

Returns

The EmailText object, allowing for method chaining.

public EmailText WithMargin(EmailSpacing vertical, EmailSpacing horizontal) #
Returns: EmailText

Sets the margin using predefined spacing values for vertical and horizontal.

Parameters

vertical HtmlForgeX.Email.EmailSpacing requiredposition: 0
The predefined vertical spacing (top and bottom).
horizontal HtmlForgeX.Email.EmailSpacing requiredposition: 1
The predefined horizontal spacing (left and right).

Returns

The EmailText object, allowing for method chaining.

public EmailText WithMargin(EmailSpacing top, EmailSpacing right, EmailSpacing bottom, EmailSpacing left) #
Returns: EmailText

Sets the margin using predefined spacing values for all sides.

Parameters

top HtmlForgeX.Email.EmailSpacing requiredposition: 0
The predefined top spacing.
right HtmlForgeX.Email.EmailSpacing requiredposition: 1
The predefined right spacing.
bottom HtmlForgeX.Email.EmailSpacing requiredposition: 2
The predefined bottom spacing.
left HtmlForgeX.Email.EmailSpacing requiredposition: 3
The predefined left spacing.

Returns

The EmailText object, allowing for method chaining.

public EmailText WithMonospace(Boolean breakAll = true) #
Returns: EmailText

Sets monospace styling for technical values (IDs, codes, hashes) without requiring CSS knowledge.

Parameters

breakAll System.Boolean = true optionalposition: 0
When true, allows breaking anywhere (useful for long hashes/tokens).
public EmailText WithMuted(Boolean muted = true) #
Returns: EmailText

Applies muted/secondary text styling (theme-aware) without requiring CSS knowledge.

Parameters

muted System.Boolean = true optionalposition: 0
public EmailText WithNaturalWrapping() #
Returns: EmailText

Sets natural text wrapping - only breaks at word boundaries. Perfect for method names like "ConfigureImageOptimization" that should stay intact.

Returns

The EmailText object, allowing for method chaining.

WithPadding(HtmlForgeX.Email.EmailSpacing spacing) #

Sets the padding using predefined spacing values.

Parameters

spacing HtmlForgeX.Email.EmailSpacing required
The predefined spacing value for all sides.

Returns

The EmailText object, allowing for method chaining.

public EmailText WithPreservedFormatting() #
Returns: EmailText

Preserves exact text formatting - maintains whitespace and prevents wrapping. Perfect for code blocks and preformatted text.

Returns

The EmailText object, allowing for method chaining.

public EmailText WithSmartWrapping() #
Returns: EmailText

Sets smart text wrapping - tries to keep camelCase and method names intact. Best for technical documentation and API references.

Returns

The EmailText object, allowing for method chaining.

WithTextDecoration 2 overloads
public virtual EmailText WithTextDecoration(TextDecoration decoration) #
Returns: EmailText

Sets the text decoration.

Parameters

textDecoration System.String requiredposition: 0
The text decoration.

Returns

The EmailText object, allowing for method chaining.

WithTextDecoration(HtmlForgeX.Email.TextDecoration decoration) #

Sets the text decoration using predefined options.

Parameters

decoration HtmlForgeX.Email.TextDecoration required
The decoration option.

Returns

The EmailText instance.

public EmailText WithWrapMode(EmailTextWrapMode wrapMode) #
Returns: EmailText

Sets the text wrapping mode for controlling how text breaks and wraps.

Parameters

wrapMode HtmlForgeX.Email.EmailTextWrapMode requiredposition: 0
The text wrapping mode.

Returns

The EmailText object, allowing for method chaining.

Properties

public String Content { get; set; } #

Gets or sets the text content.

public List<String> Lines { get; } #

Gets the collection of text lines for multi-line content support. When populated, Content is ignored.

public virtual String FontFamily { get; set; } #

Gets or sets the font family.

public virtual String FontSize { get; set; } #

Gets or sets the font size.

public virtual String LineHeight { get; set; } #

Gets or sets the line height.

public virtual String Color { get; set; } #

Gets or sets the text color.

public virtual String TextAlign { get; set; } #

Gets or sets the text alignment.

public virtual String FontWeight { get; set; } #

Gets or sets the font weight.

public virtual String TextDecoration { get; set; } #

Gets or sets the text decoration.

public String BackgroundColor { get; set; } #

Gets or sets the background color.

public Boolean LineBreak { get; set; } #

Gets or sets whether to include line break.

public EmailTextWrapMode WrapMode { get; set; } #

Gets or sets the text wrapping mode for controlling how text breaks and wraps.

public Boolean Muted { get; set; } #

Gets or sets whether this text should be rendered as muted/secondary text. Uses a stable hfx-muted hook for dark mode support.