我要做一个发邮件的系统.
想发html邮件.现在我想用富文本框自己做一个编辑器,如果在里面有加粗之类的字体,我应该把其转换为html ,有没有一个现成的方法,或者用代码写一个方法呢?有高手知道吗?谢谢.
想发html邮件.现在我想用富文本框自己做一个编辑器,如果在里面有加粗之类的字体,我应该把其转换为html ,有没有一个现成的方法,或者用代码写一个方法呢?有高手知道吗?谢谢.
解决方案 »
- System.Text.Encoding.Unicode这句是什么意思?有什么作用?
- datatable的排序问题
- 让人狂抓的JS的正侧表达式
- 使用checkbox在datagridview里选择同时删除多行的问题
- Winform,如何把webclient获取的cookie写到系统里面,再调用ie显示页面
- 一个关于XML文件读取的简单问题,请速马版主进来看看,也请其它高手指点一下
- .Net编写的类库能不能有入口函数?
- 如何让绑定在dataset的dataGrid不显示某个字段?
- 有关鼠标左右键的问题
- 请问,如何以编程的方式创建SQL server的实例的?
- WinForm中ToolTip的问题:如何让它永远显示,除非鼠标移开.
- 请问西安交大通用软件公司怎么样?
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")
<html>
<body>
<B>X</B>
</body>
</html>有没有这样一个方法?
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
我现我已经基本上解决这个问题了.我把富文本改成AxWebBrowser,它里面有一个方法是可以解决由普通变成html的,现在已经可以变粗,下划线等,但还有一点问题,就是不能设字体大小,字体颜色, 有谁知道吗?请继续指点.
4号群已经开放:23266396
请大家赶快加入!