Demo

<< Click to Display Table of Contents >>

Navigation:  Appendix > MIME Import / Export >

Demo

Instead of creating a new demo, we decided to enhance the WebBrowser application and add 2 buttons, "Load MIME" and "SaveMime".

 

First we need to add WPIOMime to the uses clause:

 

uses

 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

 Dialogs, StdCtrls, Buttons, WPRTEDefs, WPCTRMemo, WPCTRRich, ComCtrls,

 ExtCtrls, wphttpget_unit, wpobj_image, WPIOMime;

 

 

To save a web archive or message file we use

 

procedure TWPWebBrowser.SaveMIMEClick(Sender: TObject);

begin

with TSaveDialog.Create(self) do

try

    Filter := 'Webarchives (*.MHT)|*.MHT|Messages (*.MSG,*.EML)|*.MSG,*.EML';

    DefaultExt := 'MHT';

    Caption:= 'Save as MIME data';

    if Execute then

    begin

      // Web Archive

      if SameText( ExtractFileExt( FileName ), '.mht' ) then

            WPRichText1.SaveToFile(FileName, false, 'MIME-noplain')

      else  WPRichText1.SaveToFile(FileName);

    end;

finally

   Free;

end;

end;

 

 

To load a MSG or MHT file we use

 

procedure TWPWebBrowser.LoadMIMEClick(Sender: TObject);

begin

  with TOpenDialog.Create(self) do

try

    Filter := 'Webarchives (*.MHT)|*.MHT|Messages (*.MSG,*.EML)|*.MSG,*.EML';

    DefaultExt := 'MHT';

    Caption:= 'Load MIME data';

    if Execute then

    begin

      WPRichText1.SaveToFile(FileName, true);

    end;

finally

   Free;

end;

end;