我要做一个发邮件的系统.
想发html邮件.现在我想用富文本框自己做一个编辑器,如果在里面有加粗之类的字体,我应该把其转换为html  ,有没有一个现成的方法,或者用代码写一个方法呢?有高手知道吗?谢谢.

解决方案 »

  1.   

    Dim str As String = "<HTML><HEAD></HEAD><BODY><u>FGBNSDFNSNSD</u></BODY></HTML>"
            Dim B() As Byte = System.Text.Encoding.GetEncoding("GB2312").GetBytes(str)
            Dim fs As New IO.FileStream("c:\a.htm", IO.FileMode.OpenOrCreate)
            fs.Write(B, 0, B.Length)
            fs.Close()
            Process.Start("iexplore.exe", "c:\a.htm")
      

  2.   

    谢谢上楼,不过我的意思不是这样的!假设我在richText 里面写了"X",如果是加粗了的,我就想自动生成html代码:
    <html>
    <body>
    <B>X</B>
    </body>
    </html>有没有这样一个方法?
      

  3.   

    有什么Active 控件可用?怎么用?能说下吗?
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Globalization;
    using System.Threading;
    using System.Drawing;
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                StringBuilder sb = new StringBuilder();
                //如果是粗体,用下面
                sb.AppendFormat(new BoldStringToHtml(),"{0}",new object[]{"Hello World !"}  );
                Console.WriteLine(sb);
                Console.WriteLine();
                //如果是不是粗体,用下面
                sb.AppendFormat(null,"{0}",new object[]{"Hello World !"}  );
                Console.WriteLine(sb);
                Console.ReadLine();
            }
        }
        /// <summary>
        /// IFormatProvider提供语言文化,ICustomFormatter提供格式化方法
        /// </summary>
        public class BoldStringToHtml : IFormatProvider, ICustomFormatter
        {
            //实现IFormatProvider
            public Object GetFormat(Type formatType)
            {
                if (formatType == typeof(ICustomFormatter))
                    return this;
                return Thread.CurrentThread.CurrentCulture.GetFormat(formatType);
            }
            //实现 ICustomFormatter
            public String Format(String format, Object arg, IFormatProvider formatProvider)
            {
                String s;
                IFormattable formattable = arg as IFormattable;
                if (formattable == null)
                    s = arg.ToString();
                else
                    s = formattable.ToString(format, formatProvider);            return " <html><body><B>" + s + "</B></body></html>";
            }    }//class 
     }//namespace
      

  5.   

    您好,谢谢上楼,我说的只是假设是初体,您这样的话就是说只针对粗体解决了我的问题,如果还有变颜色.加下划线,等html标记呢?这还是解决不了问题的,而我要的是一个公用的方法.
    我现我已经基本上解决这个问题了.我把富文本改成AxWebBrowser,它里面有一个方法是可以解决由普通变成html的,现在已经可以变粗,下划线等,但还有一点问题,就是不能设字体大小,字体颜色, 有谁知道吗?请继续指点.
      

  6.   

    http://chinasf.cnblogs.com/archive/2005/04/26/145773.html
      

  7.   

    .net技术群-4号
    4号群已经开放:23266396
    请大家赶快加入!