RuleSetAddTagRemovalRule Method |
Namespace: MailBee.Html
Exception | Condition |
---|---|
MailBeeInvalidArgumentException | tagName is a null reference (Nothing in Visual Basic) or an empty string. |
The condition when this rule satisfies is the same as for ProcessingCondition rule (created with AddTagProcessingCondition(String, TagAttributeCollection) method). See AddTagProcessingCondition(String, TagAttributeCollection) topic for the details which apply to the HTML processing rules of all types.
The action for this rule removes the matching tag with all its inner contents.
// To use the code below, import these namespaces at the top of your code. using System; using MailBee.Mime; using MailBee.Html; class Sample { static void Main(string[] args) { // Load HTML message from file. MailMessage message = new MailMessage(); message.LoadMessage(@"C:\Temp\message.eml"); Processor htmlProcessor = new Processor(); htmlProcessor.Dom.OuterHtml = message.BodyHtmlText; RuleSet rules = new RuleSet(); rules.AddTagRemovalRule("img", null); htmlProcessor.Dom.Process(rules, null); // Process the rule and display the results. Console.WriteLine(htmlProcessor.Dom.ProcessToString(rules, null)); } }