TIdMessage * IdMessageSave = new TIdMessage (NULL);
IdMessageSave-> Clear ();
IdMessageSave-> MessageParts-> Clear ();
IdMessageSave-> CharSet = "koi8-r";
IdMessageSave-> AttachmentEncoding = "MIME";
IdMessageSave-> ContentType = "text / plain; charset = \" koi8-r
\ ";";
IdMessageSave-> Encoding = meMIME;
IdMessageSave-> From-> Address = WIN_TO_KOI (this-> From);
IdMessageSave-> Recipients-> EMailAddresses = WIN_TO_KOI (this->
To);
IdMessageSave-> Subject = WIN_TO_KOI (this-> Subject);
IdMessageSave-> Body-> Text = WIN_TO_KOI (this-> Body);
IdMessageSave-> SaveToFile (this-> Path);
IdMessageSave-> ~ TIdMessage ();
When migrating to the CodeGear RAD Studio 2009 letter written to the
file, but instead of Cyrillic letters are displayed signs of "??????"
Here's an example of a saved message:
From: "aa...@com.net" <aa...@com.net>
Subject: ???????? ?????????
To: bb...@com.net
Content-Type: text / plain; charset = "koi8-r";
MIME-Version: 1.0
Date: Sun, 25 Jan 2009 18:39:11 +0300
???? ??????????, ???????? ?????? ??????? ?????????? ? ????????? ??????, ?????????? ??
BDS2008.
?????? ? ?????? ?????????????? ????? Indy10.
??? ???????????? ?????? ?????? ????? ????????? ?
IdMessage, ?????? ??????? ??????????? ? ???? ??? ??????????? ????????
Tried to maintain through the flow, the result is the same, the flow
has become question marks
TMemoryStream * buffer = new TMemoryStream ();
IdMessageSave-> SaveToStream (buffer);
TStringList * mail_raw_str = new TStringList ();
buffer-> Position = 0;
mail_raw_str-> LoadFromStream (buffer);
mail_raw_str-> SaveToFile (this-> Path);
Search on the Internet suggested that the problem is hidden in Indy in
the method TIdMessage:: SaveToStream (...).
Actually the question, how to fix this bug?
PS: The function WIN_TO_KOI
UnicodeString WIN_TO_KOI (UnicodeString str)
(
UnicodeString res_str;
UnicodeString SKoi =
"ЈіеАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя;
UnicodeString SWin =
"eETyuabtsdefghiyklmnopyarstuzhvyzsheschchYuABTsDEFGHIYKLMNOPYaRSTUZhVYZShESchCh;
int k;
for (int i = 1; i <= str.Length (); i + +)
(
int pos = AnsiPos (str [i], SWin);
if (pos == 0) (res_str + = str [i];)
else (res_str + = SKoi [pos];)
)
return res_str;
)