using System;
using System.Web;
using CDO;
using System.Text;
using System.Runtime.InteropServices.ComTypes;
using System.Web.Mail;
using ADODB;
 
namespace Venetian.Portal.BO.ContentManagement
{
    public class SaveFile
    {
        //private ctor as our methods are all static here
        private SaveFile()
        {
 
        }
 
        public static byte[] SaveWebPageToMHTFile(string url)
        {
            //bool result = false;
            CDO.Message msg = new CDO.MessageClass();
            byte[] byteArray;
            ADODB.Stream stm = null;
            try
            {
                msg.MimeFormatted = true;
                msg.CreateMHTMLBody(url, CDO.CdoMHTMLFlags.cdoSuppressNone, "", "");
                stm = msg.GetStream();
                IStream iStream = (IStream)stm;
                byteArray = new byte[stm.Size];
                IntPtr ptrCharsRead = IntPtr.Zero;
                iStream.Read(byteArray, stm.Size, ptrCharsRead);
 
                //System.IO.Stream stream = (System.IO.Stream)msg.GetStream();
                //stm.SaveToFile(filePath, ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
                msg = null;
                stm.Close();
                //result = true;
            }
            catch
            { throw; }
 
            return byteArray;
        }
 
    }
}
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: Convert to Mhtml

That was inspiring,
converting to MHTML is much more easier than I thought
Anyway, thanks for the post 8/18/2009 12:49 PM | web development company

Post a comment





 

 

News

Employers
Soppa Group India
iSmart Panache Inc
R Systems Internationals Ltd
Technovate eSolutions Pvt Ltd
The contents of this blog are my personal opinion and do not represent in any way the view of my employer.
These postings are provided "AS IS" with no warranties, and confer no rights.

Google PR™ - Post your Page Rank with MyGooglePageRank.com

Archives

Post Categories

Image Galleries

Articles & Magazines

ASP.Net 2.0 Compilation

ASP.Net, Blogs I refer...

Atlas

Dost

Drivers and Software Download

Garhwal

Travel Domain

WSS and WebParts

Syndication: