MailMessage.GetHtmlBodyText

GetHtmlBodyText(bool)

Gets the text of the HTML body without the markup.

public virtual string GetHtmlBodyText(bool showUrl)
ParameterTypeDescription
showUrlBooleantrue to write the URLs of hyperlinks after their text.

Return Value

The text of the HTML body.

Examples

The following example shows how to get an email message�s HTML body as plain text.

[C#]

var eml = MailMessage.Load("HtmlWithUrlSample.eml");
var bodyWithUrl = eml.GetHtmlBodyText(true);// body will contain URL
var bodyWithoutUrl = eml.GetHtmlBodyText(false);// body will not contain URL

Console.WriteLine($@"Body with URL: {bodyWithUrl}");
Console.WriteLine($@"Body without URL: {bodyWithoutUrl}");

[Visual Basic]

Dim eml = MailMessage.Load("HtmlWithUrlSample.eml")
Dim bodyWithUrl = eml.GetHtmlBodyText(True)
Dim bodyWithoutUrl = eml.GetHtmlBodyText(False)

Console.WriteLine($"Body with URL: {bodyWithUrl}")
Console.WriteLine($"Body without URL: {bodyWithoutUrl}")

See Also


GetHtmlBodyText(HyperlinkRenderingCallback)

Gets the text of the HTML body without the markup, rendering hyperlinks with a custom method.

public virtual string GetHtmlBodyText(HyperlinkRenderingCallback hyperlinkRenderingCallback)
ParameterTypeDescription
hyperlinkRenderingCallbackHyperlinkRenderingCallbackThe method that renders each hyperlink as text.

Return Value

The text of the HTML body.

See Also