发送邮件字符转换

      //將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 />", "\n"); 
            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("\n", " <br/>"); 
            strContent = strContent.Replace(" ", " "); 
            return strContent; 

        } 

 

posted on 2014-07-04 14:54  strangeman  阅读(260)  评论(0编辑  收藏  举报

导航