发送邮件字符转换

      //將html轉為text 
        public string HtmlToText(string strContent) 
        { 
            strContent = strContent.Replace("&amp", "&"); 
            strContent = strContent.Replace("''", "'"); 
            strContent = strContent.Replace("&lt", " <"); 
            strContent = strContent.Replace("&gt", ">"); 
            strContent = strContent.Replace("&lt", "chr(60)"); 
            strContent = strContent.Replace("&gt", "chr(37)"); 
            strContent = strContent.Replace("&quot", """); 
            strContent = strContent.Replace(";", ";"); 
            strContent = strContent.Replace(" <br />", "
"); 
            strContent = strContent.Replace(" ", " "); 
            return strContent; 
        } 

        //將text轉為html 
        public string TextToHtml(string strContent) 
        { 
            strContent = strContent.Replace("&", "&amp"); 
            strContent = strContent.Replace("'", "''"); 
            strContent = strContent.Replace(" <", "&lt"); 
            strContent = strContent.Replace(">", "&gt"); 
            strContent = strContent.Replace("chr(60)", "&lt"); 
            strContent = strContent.Replace("chr(37)", "&gt"); 
            strContent = strContent.Replace(""", "&quot"); 
            strContent = strContent.Replace(";", ";"); 
            strContent = strContent.Replace("
", " <br/>"); 
            strContent = strContent.Replace(" ", " "); 
            return strContent; 

        } 
原文地址:https://www.cnblogs.com/profession/p/3824382.html