We help IT Professionals succeed at work.

Turkish Language character problem when sending e-mail using indy 10

mhanefitel
mhanefitel asked
on
Hi,
    Below is the code Delphi BDS 2006 Indy 10. When i send e-mail using Turkish language character i get incorrect wiew on e-mail client side.

On MS Outlook 2007 :

Subjet : ýýýý ÜÜÜ ÞÞÞ ÇÇÇ ÝÝÝ ÐÐÐ ÖÖÖ ööö ððð ççç þþþ
Body : iiii ÜÜÜ SSS ÇÇÇ III GGG ÖÖÖ ööö ggg ççç sss

On Yahoo :
Subject : ýýýý ÜÜÜ ÞÞÞ ÇÇÇ ÝÝÝ ÐÐÐ ÖÖÖ ööö ððð ççç þþþ (incorrect view)
Body : ¿¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿ ¿¿¿  (incorrect view)

     How can i fix this problem? I want to send e-mail using Turkish language character and make sure that my e-mail is viewed on client side correctly.(correct Turkish language character are attached on jpeg file. )
     Thanks in advance.




 
procedure TForm1.Button1Click(Sender: TObject);
var Temp : String;
   mailMessage : TIdMessage;
   SMTPConnection : TIdSMTP;
   tempCharSet : String;
   tempEncoding : char;
   tempTransfer : TTransfer;
begin
  Screen.Cursor := crHourGlass;//mouse bekleme

  try
      mailMessage    := TIdMessage.Create;
      SMTPConnection := TIdSMTP.Create;

      mailMessage.ClearHeader;

   //   tempCharSet  := 'ISO-8859-9';
     // tempEncoding := 'B';
    //  tempTransfer := bit8;
    //  mailMessage.InitializeISO(tempTransfer,tempEncoding,tempCharSet);

      mailMessage.ContentTransferEncoding := '8bit';
      mailMessage.CharSet                 := 'ISO-8859-9';


      with mailMessage do
      begin
         Clear;
         From.Text                 := _fromEMail;
         From.Name                 := _fromName;
         ReplyTo.EMailAddresses    := '';
         Priority                  := mpNormal;
         Recipients.EMailAddresses := _toEMail;
         Subject                   := 'iiii ÜÜÜ SSS ÇÇÇ III GGG ÖÖÖ ööö ggg ççç sss';
      end;
      mailMessage.Body.Clear;
      mailMessage.ContentType := 'text/html';
      mailMessage.Body.Add('<html>');
      mailMessage.Body.Add('<head></head>');
      mailMessage.Body.Add('<body>');
      TEMP := mailMessage.Subject;
      mailMessage.Body.Add(TEMP);
      mailMessage.Body.Add('</body>');
      mailMessage.Body.Add('</html>');


      SMTPConnection.Username := _userName;
      SMTPConnection.Password := _userPass;
      SMTPConnection.Host     := _serverName;
      SMTPConnection.Port     := _serverPort;

      {now we send the message}
      SMTPConnection.Connect;
      try
         SMTPConnection.Send(mailMessage);
      finally
         SMTPConnection.Disconnect;
      end;
  finally
      SMTPConnection.Free;
      mailMessage.Free;
  end;
  Screen.Cursor := crDefault;//mosue normal
end;

Open in new window

CorrectCharacters.jpg
Comment
Watch Question

Commented:
try this:

ISO/IEC 8859-3

Author

Commented:
ISO/IEC 8859-3 solution does not work.
Here is the solution.

//I added this procedure and it works fine.
procedure TForm1.mailMessageInitializeISO(var VTransferHeader: TTransfer;
  var VHeaderEncoding: Char; var VCharSet: string);
begin
      VCharSet := 'iso-8859-9' ;
end;

Author

Commented:
I solved problem myself.