Sample code for 30+ languages & platforms
Delphi DLL

Load MIME from XML

See more MIME Examples

Demonstrates the Chilkat Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML. The only argument is the XML string.

Background: Chilkat can represent a MIME tree as XML — headers as elements, parameters as attributes — which is convenient for inspecting or editing structure with XML tools. This is the inverse of GetXml: it rebuilds the full MIME object from that representation. Invalid XML leaves the current object unchanged.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
mime: HCkMime;
xmlText: PWideChar;

begin
success := False;

//  Demonstrates the Mime.LoadXml method, which reconstructs a MIME tree from Chilkat's MIME XML.
//  The only argument is the XML string.

mime := CkMime_Create();

//  Chilkat MIME XML (as produced by GetXml).
xmlText := '<mime><contentType>text/plain</contentType><body>Hello.</body></mime>';

success := CkMime_LoadXml(mime,xmlText);
if (success = False) then
  begin
    Memo1.Lines.Add(CkMime__lastErrorText(mime));
    Exit;
  end;

Memo1.Lines.Add('Content-Type: ' + CkMime__contentType(mime));

CkMime_Dispose(mime);