Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Re: Sending a SMTP message with UTF-8 subject

www.cryer.info
Managed Newsgroup Archive

Re: Sending a SMTP message with UTF-8 subject

Subject:Re: Sending a SMTP message with UTF-8 subject
Posted by:"Richard" (ritchie8..@yahoo.com)
Date:Tue, 27 Nov 2007 10:13:13

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:474b647a$1@newsgroups.borland.com...

>
> As for the headers - when you assign a WideString to an AnsiString, it is
> converted to Ansi or MBCS by the RTL, depending on your system
> configuration.  Indy will convert that back to WideString when performing
> the actual UTF-8 encoding, or theoritically nothing should get lost.

Yes. After many tests,  the only think that seems to work is NoEncode:=
true. It would be wonderful if you could asign a string to the headers
without it being encoded. Something like:

Mess.Subject:=
'=?utf-8?B?IdEncoder.EncodeString(UTF8Encode(SomeWideString))+'?=';

Unfortunally, doing so encodes the string once more giving bad results.

I have tried to modify the headers directly like:

Mess.Headers.Value['Subject']:=
'=?utf-8?B?IdEncoder.EncodeString(UTF8Encode(SomeWideString))+'?=';

but this does nothing good either.

Setting noencode to true does the trick but the it is a pain to enode the
whole message with attachments and all manually...

I'll take a look to TidMessage's code to see if I can disable the
autoencoding of the ´headers without affecting the rest, but I somehow doubd
it.

Some idea I had was to save the message to a stream, then replace the
headers on the stream and load the modifies message to the Message but this
doesn't seem to work for some reason... Oh well...

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive