Converting in-memory HTML to email

Question:

We need to send HTML mail which will embed all the images and style sheets. In order to achieve this we use MHT class. Everything is fine if we specify URL as source for converting: Mht::GetEmail( szURL ); But, unfortunately, our HTML page isn’t publicly available (it cannot be accessed through URL address) and there is no way to store it locally on the server. Hence, we need to create MHT web archive from in-memory HTML string by using the Mht::HtmlToMHT method. But, unfortunately, the method doesn’t embed any images (in base64 encoding). We use the following code snippet:

         Mht mht = new Mht();
         mht.UnlockComponent("AnythingWorksFor30DayTrial");
         mht.EmbedImages = true;
         string szMht = mht.HtmlToMHT(szMyHtmlPage);
         Chilkat.MailMan man = new Chilkat.MailMan();
         man.UnlockComponent("AnythingWorksFor30DayTrial");
         base.Email = man.LoadMime(szMht);

Answer:

When converting an in-memory HTML string, the Chilkat MHT component will need to know how to locate relative URL references. Try setting the Mht.BaseUrl property to the directory path (or URL) that is the base for the relative references. Chilkat MHT will handle both file directory paths as well as URLs in the "BaseUrl" property.