How to get back LineEnding when I use TIMAPSend to read Email with IMAP4? SOLVED lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- senglit · 2022-01-01 13:49 Hi all, When I use TIMAPSend to read Email with IMAP4 I coded like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...         imap.SearchMess(’(HEADER MESSAGE-ID ‘+msgIds[i]+’)‘,msgs);  //only the mails with Message-Id in TStringList msgIds are needed           imap.FetchMess(StrToInt(msgs[0]),MimeMess.Lines);           ...         MimeMess.MessagePart.DecodePart;           setlength(s,MimeMess.MessagePart.DecodedLines.Size);           MimeMess.MessagePart.DecodedLines.Read(s[1],length(s));           Mem o1.Lines.AddStrings(ConvertEncodingToUTF8(s,CharSets[i],Encoded));...  The symble ’ should be ', but it will be traslated to ''' when it comes to '(  CharSets is the charset of the email I read from Message Header. It works. I can read mail with charset us-ascii, cp936, cp950..... The problem now is that DecodedLines is TMemoryStream without LineEnding(#13#10), which made all of the email content connected into 1 line. I also tried code like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...         imap.SearchMess(’(HEADER MESSAGE-ID ‘ + msgIds[i]+’) ‘,msgs);  //only the mails with Message-Id in TStringList msgIds are needed         ...           imap.FetchMess(StrToInt(msgs[0]),MimeMess.Lines);           ...           MimeMess.MessagePart.DecodePart;           for j:=0 to MimeMess.MessagePart.PartBody.Count-1 do begin              Me mo1.Lines.Add(ConvertEncodingToUTF8(MimeMess.MessagePart.PartBody[j],C harSets[i],Encoded));           end;... With this the mail content can't be convert correctly to UTF8. I got something like "s2+sT6RArdNCSUe9c71Yqrq2bKXzCgpSb3kKCg==". How can I get the mail content with correct LineEndings? Thanks a lot! ---------------------------------------------------------------------- senglit · 2022-01-02 15:37 I think I found the way: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...         imap.SearchMess('(HEADER MESSAGE-ID '+msgIds[i]+')',msgs);  //only the mails with Message-Id in TStringList msgIds are needed           imap.FetchMess(StrToInt(msgs[0]),MimeMess.Lines);           ...         MimeMess.DecodeMessage;           MimeMess.MessagePart.DecodePart;           MimeMess.MessagePart.PartB ody.LoadFromStream(MimeMess.MessagePart.DecodedLines); //copy the DecodedLines back to PartBody!!!!!           for j:=0 to MimeMess.MessagePart.PartBody.Count-1 do begin              Memo1.Line s.Add(ConvertEncodingToUTF8(MimeMess.MessagePart.PartBody[j],CharSets[ i],Encoded));           end;...