MailMessage.GetHtmlBodyText

GetHtmlBodyText(bool)

Gets the message html body as plain text. This method parses the HtmlBody property and returns plain text content ignoring the html markup.

public virtual string GetHtmlBodyText(bool showUrl)
ParameterTypeDescription
showUrlBooleanDefines need to show URL in text.

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 message htmlbody as plain text.

public virtual string GetHtmlBodyText(HyperlinkRenderingCallback hyperlinkRenderingCallback)
ParameterTypeDescription
hyperlinkRenderingCallbackHyperlinkRenderingCallbackReference to custom method for handling rendering of hyperlink.

Return Value

Result string of custom handling rendering of hyperlink.

See Also