Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jan : Message parts problem D&/indy 10.0.52

www.cryer.info
Managed Newsgroup Archive

Message parts problem D&/indy 10.0.52

Subject:Message parts problem D&/indy 10.0.52
Posted by:"Jacques" (jacques.no..@btinternet.com)
Date:Thu, 26 Jan 2006 17:07:25

I am having problems retrieving the body of a message. Basically, what i
want to do is to download the messages from the server and then immediately
add them to my local database. Now, to download the headers, i use
pop.retrieveheaders(), which does the job fine, but for the actual bodytext
i need to know if msg is HTML because i have a table field that needs to be
marked appropriately, to enable the app to format the text later on. To get
the msgbody info(i.e HTML/PLAIN etc) i use  pop.retrieve() and then run a
separate loop to get the info i want. When i do this, the msgbody or text
part comes up empty, i sent test msgs with a msgbody, so i dont know why it
comes out empty. Also, i call both pop.retrieve and pop.retrieveheaders() at
different times in the same loop, could this be the problem?

Here's the code:
if  msgcount > 0 then //messages on server prepare to download
begin
for intindex:= 1 to msgcount do begin //START MAIN LOOP
Screen.Cursor := crHourGlass;
statusbar1.Panels[1].Text:=(format('Downloading Messages... %d of %d',
[intIndex, msgcount]));
Application.ProcessMessages;
Mess.Clear;
//get the message headers
pop1.RetrieveHeader(intIndex, Mess);
//insert msg headers in db
tmsg.Active:=true;
tmsg.Insert;
tmsg.FieldByName('from').Text:=mess.From.address;
tmsg.FieldByName('to').Text:=mess.Recipients.EMailAddresses;
tmsg.FieldByName('subject').Text:=mess.Subject;
tmsg.FieldByName('msgdate').Text:=formatdatetime('dd/mm/yyy
hh:mm:ss',mess.Date);
tmsg.FieldByName('checked').Text:='0';
tmsg.FieldByName('isatt').Text:='0';

//************************************get the
msgBody***************************
pop1.Retrieve(intindex,Mess);
for I:= 0 to Pred(Mess.MessageParts.Count) do begin
  if Mess.MessageParts.Items[I] is TIdText then
begin
if (mess.MessageParts.Items[I].ContentType) = 'text/HTML'  then  begin

//put msgbody in msgbody field of database
         tmsg.FieldByName('msgbody').asstring:=tidText(mess.MessageParts.Items[I]).Body.Text;
        tmsg.FieldByName('ishtml').asinteger:=1;//1 for Yes, 0 for No

          end
end; // end msgparts check

//post the data
tmsg.Post;

end; //END MAIN LOOP

Replies:

www.cryer.info
Managed Newsgroup Archive