Renderizar hiperenlaces con estilo personalizado

Contents
[ ]

Puede haber momentos en los que necesite mostrar hiperenlaces con un estilo específico basado en los requisitos de su aplicación. Para eso, Aspose.Email proporciona HyperlinkRenderingCallback. Puede pasar el HyperlinkRenderingCallback como un parámetro de MailMessage.GetHtmlBodyText.

El siguiente fragmento de código le muestra cómo usar HyperlinkRenderingCallback para mostrar hiperenlaces utilizando su propio estilo personalizado.

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET
public static void Run()
{
string dataDir = RunExamples.GetDataDir_Email();
var fileName = dataDir + "LinksSample.eml";
MailMessage msg = MailMessage.Load(fileName);
Console.WriteLine(msg.GetHtmlBodyText(RenderHyperlinkWithHref));
Console.WriteLine(msg.GetHtmlBodyText(RenderHyperlinkWithoutHref));
}
private static string RenderHyperlinkWithHref(string source)
{
int start = source.IndexOf("href=\"") + "href=\"".Length;
int end = source.IndexOf("\"", start + "href=\"".Length);
string href = source.Substring(start, end - start);
start = source.IndexOf(">") + 1;
end = source.IndexOf("<", start);
string text = source.Substring(start, end - start);
string link = string.Format("{0}<{1}>", text, href);
return link;
}
private static string RenderHyperlinkWithoutHref(string source)
{
int start = source.IndexOf(">") + 1;
int end = source.IndexOf("<", start);
string text = source.Substring(start, end - start);
return text;
}