Send mail with German Umlauts and other UTF-8 characters

Download Source Code

This sample demonstrates how to set up the TclMailMessage component correctly for transferring German Umlauts and other UTF-8 characters.

procedure TForm1.Button1Click(Sender: TObject);
var
  msg: TclMailMessage;
begin
  msg := TclMailMessage.Create(nil);
  try
    msg.CharSet := 'UTF-8';
    msg.Encoding := cmNone;
    msg.BuildMessage('Text with umlauts ÄÖÜß', '');
    msg.Subject := 'subject line';
    msg.From.FullAddress := 'john@example.com';
    msg.ToList.EmailAddresses := 'peter@domain.com';
 
    msg.SaveMessage('mail-utf8-autodetect.eml');
 
    msg.CharSet := 'UTF-8';
    msg.Encoding := cm8Bit;
    msg.BuildMessage('Text with umlauts ÄÖÜß', '');
    msg.Subject := 'subject line';
    msg.From.FullAddress := 'john@example.com';
    msg.ToList.EmailAddresses := 'peter@domain.com';
 
    msg.SaveMessage('mail-utf8-8bit.eml');
 
    msg.CharSet := 'cp1252';
    msg.Encoding := cm8Bit;
    msg.BuildMessage('Text with umlauts ÄÖÜß', '');
    msg.Subject := 'subject line';
    msg.From.FullAddress := 'john@example.com';
    msg.ToList.EmailAddresses := 'peter@domain.com';
 
    msg.SaveMessage('mail-latin1-8bit.eml');
 
    ShowMessage('Done');
  finally
    msg.Free();
  end;
end;

Add Feedback