Sample code for 30+ languages & platforms
Delphi DLL

Load MIME from a StringBuilder

See more MIME Examples

Demonstrates the Chilkat Mime.LoadMimeSb method, which parses complete MIME text from a StringBuilder and replaces the current MIME. The only argument is the StringBuilder.

Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Background: When the MIME text already lives in a StringBuilder — assembled in memory, or read and lightly edited — this loads it directly without an intermediate string copy. Its parsing behavior matches LoadMime; the difference is purely the source. For content that might include arbitrary binary bytes, use the BinData loader instead.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
sb: HCkStringBuilder;
mime: HCkMime;

begin
success := False;

//  Demonstrates the Mime.LoadMimeSb method, which parses complete MIME text from a StringBuilder
//  and replaces the current MIME.  The only argument is the StringBuilder.

//  Put the MIME text into a StringBuilder (here loaded from a file, but it could come from
//  anywhere).
sb := CkStringBuilder_Create();
success := CkStringBuilder_LoadFile(sb,'qa_data/message.eml','utf-8');
if (success = False) then
  begin
    Memo1.Lines.Add(CkStringBuilder__lastErrorText(sb));
    Exit;
  end;

mime := CkMime_Create();
success := CkMime_LoadMimeSb(mime,sb);
if (success = False) then
  begin
    Memo1.Lines.Add(CkMime__lastErrorText(mime));
    Exit;
  end;

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

CkStringBuilder_Dispose(sb);
CkMime_Dispose(mime);