aspNetEmail

HtmlEncodeOption Enumeration

Controls Html Encoding for non Ascii characters.

public enum HtmlEncodeOption

Remarks

Some mail gateways do not like non-ascii content. Also, some email clients prefer that all non-ascii characters be Html encoded. This option controls the HtmlUtility class, and can encode any non-ascii characters.

For example, if the NamedCodes option is selected, a © would be converted to &copy. However, if the NumberedCodes option was selected, it would be converted to ©

Example

[C#]
            
            HtmlUtility utility = new HtmlUtility();
            string url = "http://www.microsoft.com";
            utility.LoadUrl( url );
            
            //convert all non-ascii characters to numbered code
            utility.HtmlEncodeOption = HtmlEncodeOption.NumberedCodes;
            
            //render the Html so it is properly formatted for email
            utility.Render( EmbedImageOption.ContentId, true );
            
            //create an EmailMessage with appropriate text and html parts
            EmailMessage email = utility.ToEmailMessage();
            
            //load To, From, Server, etc... values from the web.config
            email.LoadFromConfig();
            
            email.Subject = "Html Utility Test";
            
            email.Send();
            
[VB.NET]
            
            Dim utility As New HtmlUtility()
            
            Dim url As String = "http://www.microsoft.com"
            utility.LoadUrl(url)
            
            'convert all non-ascii characters to numbered code
            utility.HtmlEncodeOption = HtmlEncodeOption.NumberedCodes
            
            'render the Html so it is properly formatted for email
            utility.Render(EmbedImageOption.ContentId, True)
            
            'create an EmailMessage with appropriate text and html parts
            Dim email As EmailMessage = utility.ToEmailMessage()
            
            'load To, From, Server, etc... values from the web.config
            email.LoadFromConfig()
            
            email.Subject = "Html Utility Test"
            
            email.Send()
            

Members

Member NameDescription
NoneDoes not modify any of the Html Content.
NamedCodes First check to see if a named Html code exists for a character, if not, the numbered Html code is used.
NumberedCodesUse Html number codes for all non-ascii content.

Requirements

Namespace: aspNetEmail

Assembly: aspNetEmail (in aspNetEmail.dll)

See Also

aspNetEmail Namespace