Jump to content

Indy SMTP does not display Greek chars properly


nickosl50

Recommended Posts

Hi,

I made a simple  Unigui app to send email to a recipient using my gmail account. While the Message subject appears correctly in Greek , the message body displays Greek char like ????. I use TIdSMP, TIdMessage and TIdSSLIOHandlerSocketOpenSSL.

 

The code that sends email is the following:

 

 

procedure Gmail(username, password, totarget, subject, body: string);
 
var
  DATA: TIdMessage;
  SMTP: TIdSMTP;
  SSL: TIdSSLIOHandlerSocketOpenSSL;
  ErrorSendMail : string;
 
begin
 
  SMTP := TIdSMTP.Create(nil);
  DATA := TIdMessage.Create(nil);
  SSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
 
  SSL.SSLOptions.Method := sslvTLSv1;
  SSL.SSLOptions.Mode := sslmUnassigned;
  SSL.SSLOptions.VerifyMode := [];
  SSL.SSLOptions.VerifyDepth := 0;
 
 
 
  DATA.CharSet := 'ISO-8859-7';
  DATA.From.Address := username;
  DATA.Recipients.EMailAddresses := totarget;
  DATA.subject := subject;
  DATA.body.text := UTF8Encode(body);
  DATA.ContentType := 'text/html';
 
 
 
  SMTP.IOHandler := SSL;
  SMTP.Host := 'smtp.gmail.com';
  SMTP.Port := 587;
  SMTP.username := username;
  SMTP.password := password;
  SMTP.UseTLS := utUseExplicitTLS;
 
 
  try
     try
       SMTP.Connect;
       SMTP.Send(DATA) ;
     except on E:Exception do
       ErrorSendMail := '' + E.Message
     end;
  finally
     if SMTP.Connected then
      begin
       SMTP.Disconnect;
       SMTP.Free;
       DATA.Free;
       SSL.Free;
 
      end;
  end;
 
 
end;
 
 
   I would appreciate if someone could give me a clue about the problem.
 
 
  Thank you very much

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...