A little method to find auto find and mark external links in a block of HTML as nofollow and add a custom class to them.

public string NofollowExternalLinks(string html, string externalClassName = "external")
{
    var doc = new HtmlDocument();
    doc.LoadHtml(html);
    foreach (var link in doc.DocumentNode.SelectNodes(@"//a[@href]"))
    {
        var att = link.Attributes["href"];
        if (att == null) continue;
        var href = att.Value;
        if (href.StartsWith("javascript", StringComparison.InvariantCultureIgnoreCase) || href.StartsWith("#", StringComparison.InvariantCultureIgnoreCase)) continue;

        var urlNext = new Uri(href, UriKind.RelativeOrAbsolute);

        // Make it absolute if it's relative
        if (urlNext.IsAbsoluteUri)
        {
            // Absolute so it's external
            link.Attributes.Append("rel", "nofollow");
            link.Attributes.Append("class", externalClassName);
        }
    }
    return doc.DocumentNode.WriteTo();
}