Delphi ActiveX Requires Chilkat v11.0.0+
Delphi ActiveX
Choose the character set for an HTML email
See more Email Object Examples
Read a UTF-8 HTML file as Unicode, then set the charset Chilkat will use when writing the MIME text. The HTML file’s input encoding and the message’s output charset are separate choices. UTF-8 can represent names from multiple writing systems.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
email: TChilkatEmail;
html: TChilkatStringBuilder;
begin
success := 0;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := TChilkatEmail.Create(Self);
email.From := 'Workshop team <events@example.com>';
success := email.AddTo('Alex Rivera','alex@example.net');
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
email.Subject := 'Workshop registration';
html := TChilkatStringBuilder.Create(Self);
success := html.LoadFile('newsletter.html','utf-8');
if (success <> 1) then
begin
Memo1.Lines.Add('Failed: html.LoadFile.');
Exit;
end;
email.Charset := 'utf-8';
email.SetHtmlBody(html.GetAsString());
success := email.SaveEml('newsletter.eml');
if (success <> 1) then
begin
Memo1.Lines.Add(email.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Saved newsletter.eml.');