这个要用CDO,但是.Net直接使用CDO有点问题,建议你将创建一个保存mht的COM组件然后在.net中调用这个组件,下面是一段vb6的代码引用Microsoft CDO for Windows 2000 Library,%SystemRoot%\System32\cdosys.dll Dim msg As CDO.Message Dim config As CDO.Configuration Dim s As ADODB.Stream
Set msg = New CDO.Message Set config = New CDO.Configuration
Dim msg As CDO.Message
Dim config As CDO.Configuration
Dim s As ADODB.Stream
Set msg = New CDO.Message
Set config = New CDO.Configuration
msg.Configuration = config
msg.CreateMHTMLBody "http://www.google.com/intl/zh-CN/", cdoSuppressNone, "", ""
Set s = msg.GetStream
s.SaveToFile "c:\g.mht"
s.Close
Set s = Nothing
Set config = Nothing
Set msg = Nothing
CDO.Configuration cfg=new CDO.ConfigurationClass();
msg.Configuration=cfg;
msg.CreateMHTMLBody("http://www.51tour.com/",CDO.CdoMHTMLFlags.cdoSuppressAll,"","");
ADODB.Stream sw=msg.GetStream(); HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=a.mht");
HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType ="text/mhtml";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
HttpContext.Current.Response.Write(sw);
HttpContext.Current.Response.End();
------------------------------------------------
大家帮我看看,为什么得不到数据流啊
{
CDO.Message msg=new CDO.MessageClass();
msg.CreateMHTMLBody(URL,CDO.CdoMHTMLFlags.cdoSuppressAll,"","");
ADODB.Stream sw=msg.GetStream();
string urlPath = HttpContext.Current.Request.ApplicationPath + "/Temp/"; //虚拟目录
string physicPath = HttpContext.Current.Server.MapPath(urlPath); //物理地址
string strFileName=Guid.NewGuid()+".mht";
sw.SaveToFile(physicPath+strFileName,ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "mht";
HttpContext.Current.Response.WriteFile(urlPath+strFileName);
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(FileName)+"");
HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType ="text/mhtml";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
HttpContext.Current.Response.Flush();
System.IO.File.Delete(physicPath+strFileName);//删除临时文件
HttpContext.Current.Response.End(); }
-----------------------------------
已解决,上边是解决方案。有好的方案可以发短信共同探讨。
而且设置了ChartSet也没用?GB2312和UTF-8都设了