EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElMessage - error with subject and body with czech charakters

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#25880
Posted: 07/30/2013 06:10:25
by medax (Standard support level)
Joined: 08/28/2012
Posts: 36

Good day,
I try demo application from folder "EldoS\SecureBlackbox.VCL\Samples\Delphi\MailBlackbox\SMTPClient". It works fine. But when I use czech characters in Subject and Body, then error occurs "Western European (ISO-8859-1) encoding error: Illegal chracter".
I try change code and I try insert line "msg.Charset := 'windows-1250';", but it did not work.
Thank you, Martin
#25881
Posted: 07/30/2013 06:18:30
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

You should set TElMessage.BodyEncoding/HeaderEncoding properties.
#25882
Posted: 07/30/2013 06:42:34
by medax (Standard support level)
Joined: 08/28/2012
Posts: 36

Thank you. Body now works.

I try code:
Code
  msg.HeaderEncoding := heAutoDetect;
  msg.SetSubject(Subject);

It not works.

Thank you, Martin
#25883
Posted: 07/30/2013 07:06:21
by Alexander Ionov (EldoS Corp.)

Quote
medax wrote:
It not works.

What does this mean? Exception? Invalid data in the encoded message? Something else?


--
Best regards,
Alexander Ionov
#25884
Posted: 07/30/2013 07:25:53
by medax (Standard support level)
Joined: 08/28/2012
Posts: 36

[QUOTEWhat does this mean? Exception? Invalid data in the encoded message? Something else?[/QUOTE]
error occurs "Western European (ISO-8859-1) encoding error: Illegal chracter".

as Subject: I send body text 'ěščřžýáíéůú', but in Outlook I see text '?????ýáíé?ú'.


I use code:
Code
const
  CHAR_SET = 'windows-1250';//'utf-8'
var
  Subject, Body: String;
...
  msg := TElMessage.Create(false);
  mmp := TElMultiPartList.Create(msg, nil);
  body_ := TElPlainTextPart.Create;

  msg.SetMainPart(mmp, False);

  msg.BodyEncoding := CHAR_SET;
  body_.SetText(Body);
  mmp.AddPart(body_);

  msg.HeaderEncoding := heAutoDetect;
  msg.SetSubject(Subject);
...


I use demo application from folder "EldoS\SecureBlackbox.VCL\Samples\Delphi\MailBlackbox\SMTPClient".

Thank you, Martin
#25885
Posted: 07/30/2013 07:35:48
by medax (Standard support level)
Joined: 08/28/2012
Posts: 36

This code works:
Code
const
  CHAR_SET = 'utf-8'ů
var
  Subject, Body: String;
...
  msg := TElMessage.Create(false);
  mmp := TElMultiPartList.Create(msg, nil);
  body_ := TElPlainTextPart.Create;
    
  msg.SetMainPart(mmp, False);
    
  msg.BodyEncoding := CHAR_SET;
  body_.CharSet := CHAR_SET;
  body_.SetText(Body);
  mmp.AddPart(body_);
    
  msg.Charset := CHAR_SET;
  msg.SetSubject(Subject);
...


Martin
#25886
Posted: 07/30/2013 07:42:50
by Alexander Ionov (EldoS Corp.)

Encodings and charsets are not the same things!
You should:
1. Set message charset:
msg.Charset := 'windows-1250';
2. Set an appropriate encoding for header. You can leave AutoDetect value;
3. Set an appropriate encoding for message body to "8bit" or "base64" or "quoted-printable"

Also, could you please to use the following code to store the message into a file instead of sending over SMTP? Then zip the file and load it to any file sharing service and post a link here.
Code
    F := TFileStream.Create('yourmsg.eml', fmCreate or fmShareDenyWrite);
    try
      Msg.AssembleMessage(F);
    finally
      FreeAndNil(F);
    end;


--
Best regards,
Alexander Ionov
#25887
Posted: 07/30/2013 07:44:19
by Alexander Ionov (EldoS Corp.)

Quote
medax wrote:
msg.BodyEncoding := CHAR_SET;

This line is not correct. See my previous message for allowed values for this property.


--
Best regards,
Alexander Ionov
#25888
Posted: 07/30/2013 07:48:22
by Alexander Ionov (EldoS Corp.)

BTW, if you don't need to create a special message structure, it's better to use TElSimpleMIMEMessage class - it's much more simpler than TElMessage.


--
Best regards,
Alexander Ionov
#25891
Posted: 07/30/2013 11:03:31
by medax (Standard support level)
Joined: 08/28/2012
Posts: 36

Thank you, I'll try it. Martin
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 2554 times

Number of guests: 2, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!