(Delphi DLL) Add Content-Length Header to a MIME Message
The AddContentLength method automatically computes the length of the MIME content and adds a Content-Length header with the correct number of bytes.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Mime;
...
procedure TForm1.Button1Click(Sender: TObject);
var
mime: HCkMime;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
mime := CkMime_Create();
// Set the MIME body:
CkMime_SetBody(mime,'This is a test');
// The complete size (in bytes) of the contents is computed,
// even if the MIME is multipart, and the Content-Length header
// is added.
CkMime_AddContentLength(mime);
// Display the MIME:
Memo1.Lines.Add(CkMime__getMime(mime));
CkMime_Dispose(mime);
end;
|