Delphi ActiveX
Delphi ActiveX
MIME Multipart Boundary and Preamble Properties
See more MIME Examples
Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.
Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
mime: TChilkatMime;
part: TChilkatMime;
mimeStr: WideString;
begin
success := 0;
mime := TChilkatMime.Create(Self);
// Create a multipart/mixed entity.
success := mime.NewMultipartMixed();
if (success = 0) then
begin
Memo1.Lines.Add(mime.LastErrorText);
Exit;
end;
// Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
// automatically in the serialized header when required.
mime.Boundary := 'example-boundary';
// UseMmDescription controls whether the conventional preamble text
// "This is a multi-part message in MIME format." is emitted. The default is 0.
mime.UseMmDescription := 1;
// Add a simple part so the multipart has content.
part := TChilkatMime.Create(Self);
success := part.SetBodyFromPlainText('First part.');
if (success = 0) then
begin
Memo1.Lines.Add(part.LastErrorText);
Exit;
end;
success := mime.AppendPart(part.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(mime.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Boundary = ' + mime.Boundary);
mimeStr := mime.GetMime();
if (mime.LastMethodSuccess = 0) then
begin
Memo1.Lines.Add(mime.LastErrorText);
Exit;
end;
Memo1.Lines.Add(mimeStr);