Hi there,

I have the following code that downloads gmail messages, and it works fine,
except the line that
writes the BODY of the email, writes the entire email in text, not just the
body part:

This is the line:  Memo1.Lines.AddStrings(MimeMess.MessagePart.Lines);

It writes something like this (this is just a part of it):

--047d7bfcfdb0b21b400544c9c4fb

Content-Type: multipart/alternative; boundary=047d7bfcfdb0b21b390544c9c4f9

--047d7bfcfdb0b21b390544c9c4f9

Content-Type: text/plain; charset=UTF-8


Stefan's Body Line 1

Stefan's Body Line 2

Stefan's Body Line 3


--047d7bfcfdb0b21b390544c9c4f9

Content-Type: text/html; charset=UTF-8

Content-Transfer-Encoding: quoted-printable

I need the correct line to ONLY write the body of the email, which is the 3
lines:

Stefan's Body Line 1

Stefan's Body Line 2

Stefan's Body Line 3

Any help would be greatly appreciated!!!

​Here is the part of the code with the issue:

        // are there any unread messages?
        cnt:=imap.StatusFolder(FolderList[i],'UNSEEN');
        if cnt>0 then
          begin
          imap.SelectROFolder(FolderList[i]);
          // get last SelectedRecent messages
          for j:=imap.SelectedCount-imap.SelectedRecent to
imap.SelectedCount do
            begin
            imap.FetchMess(j,MimeMess.Lines);
            // deocde header and body
            MimeMess.DecodeMessage;
            Memo1.Lines.Add('-------------------------------------------
-------');
            Memo1.Lines.Add(MimeMess.Header.From);
            Memo1.Lines.Add(MimeMess.Header.Subject);
            // is this multipart
            spcnt:=MimeMess.MessagePart.GetSubPartCount();
            if spcnt>0 then
              //get all parts
              for cnt:=0 to spcnt-1 do
                begin
                MimePart:=MimeMess.MessagePart.GetSubPart(cnt);
                MimePart.DecodePart;
                Memo1.Lines.Add('-----------------------');
                Memo1.Lines.Append(MimePart.Primary+' ;
'+MimePart.Secondary);
                Memo1.Lines.Add('-----------------------');
                setlength(s,MimePart.DecodedLines.Size);
                MimePart.DecodedLines.Read(s[1],length(s));
                Memo1.Lines.Add(s);
                end
            else
              //print body
*              Memo1.Lines.AddStrings(MimeMess.MessagePart.Lines);*
            end;
          end;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to