html转成MHT乱码问题?为什么已经设置成UTF8,还会出现乱码?并且转换后页面IE默认为GB2312?
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 = "utf-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
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();
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 = "utf-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
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();
msg.MDNRequested = true;
msg.MimeFormatted = true;
msg.CreateMHTMLBody(url, CDO.CdoMHTMLFlags.cdoSuppressNone, string.Empty,
string.Empty);
ADODB.Stream stream = msg.GetStream();
stream.Charset = "utf-8";
string strText = stream.ReadText();