Board index » delphi » TIdMessage.Messageparts.Items[i].ContentType

TIdMessage.Messageparts.Items[i].ContentType

Many people have posted questions about this before asking about the status of this or where about's they need to look at the indy source to get it to populate with the correct information, but no one seems to have answered or given any status updates on any of them.

This is quite an important fix that is needed as this is what is used to determine whever the information is HTML or Text thus allowing correctly display for the user to see the information.  

I was just doing a check for some tags but I am receiveing email which do not have <html> and just have HTML commands in, which is a bit difficult and slow to check for every kind of HTML tag there is to determine whether it is an HTML email.

Anyone, fixed this or are the Indy team looking into this currently?

Kinda of a show stopper for quite a few people as I understand the savetofile suffers with problems of this as well.

Thanks
Inferno

 

Re:TIdMessage.Messageparts.Items[i].ContentType


If someone can point me in the right directions, I'll gladly attempt a fix
to help out with the development of the components, I have found in
IdMessageCoder two procedures

* InitializeHeaders(AMsg: TIdMessage);
*  ReadHeader;

I'm assuming this is what is meant to do the decoding, currently both
procedures are empty.

Inferno

Quote
"Inferno" <lee.bamb...@Jalco.co.uk> wrote in message

news:3bbc7b67$1_1@dnews...
Quote

> Many people have posted questions about this before asking about the

status of this or where about's they need to look at the indy source to get
it to populate with the correct information, but no one seems to have
answered or given any status updates on any of them.
Quote

> This is quite an important fix that is needed as this is what is used to

determine whever the information is HTML or Text thus allowing correctly
display for the user to see the information.
Quote

> I was just doing a check for some tags but I am receiveing email which do

not have <html> and just have HTML commands in, which is a bit difficult and
slow to check for every kind of HTML tag there is to determine whether it is
an HTML email.
Quote

> Anyone, fixed this or are the Indy team looking into this currently?

> Kinda of a show stopper for quite a few people as I understand the

savetofile suffers with problems of this as well.
Quote

> Thanks
> Inferno

Re:TIdMessage.Messageparts.Items[i].ContentType


I agree.

It's a showstopper to me as well - together with the formatting problems
when storing quoted printable.

I hope Team Indy will follow up on this thread, with a status.

I changed in unit IdMessageClient the function "ProcessTextPart"  - see the
bottom of this mail - I hope this can help you. - Let me know how it goes...

best regards
John Romedahl

***************************

function ProcessTextPart(ADecoder: TIdMessageDecoder): TIdMessageDecoder;
 var
    LDestStream: TStringStream;
begin
    LDestStream := TStringStream.Create('');
    try
      Result := ADecoder.ReadBody(LDestStream, MsgEnd);
      with TIdText.Create(AMsg.MessageParts) do
      begin
        Body.Text := LDestStream.DataString;
        Headers.AddStdValues(ADecoder.Headers); // << added this line
      end;
    finally
      ADecoder.Free;
      FreeAndNil(LDestStream);
    end;
  end;

Re:TIdMessage.Messageparts.Items[i].ContentType


Quote
"John Romedahl" <j...@adr.dk> wrote in message news:3bbcc072$1_2@dnews...
> I hope Team Indy will follow up on this thread, with a status.

I don't know if this is what you're hoping for, but here goes...

Quote
> I changed in unit IdMessageClient the function "ProcessTextPart"  - see
the
> bottom of this mail - I hope this can help you. - Let me know how it

goes...

Your suggestion has been forwarded to the Indy developer(s) that maintain
the modules in question.  Your change makes perfect sense to me, but then
again - I just write docs.<g>  I've also suggested that a similar operation
may be needed in ProcessAttachment.

Quote
> together with the formatting problems
> when storing quoted printable.

Maybe I'm dense... but I still don't understand what (exactly) is broken in
the quoted-printable coders.  If someone can  send a specific example of the
output you're getting, and what you're expecting, perhaps I can be of more
assistance.  Right now, I'm not sure what we're looking for.

I'm looking forward to more info on this problem.

Thanks for the feedback...

Don

Re:TIdMessage.Messageparts.Items[i].ContentType


Sorry Don siders I accidently replied to you instead of the newgroup I do
apologise.

Thanks For forwarding that info on to the developers, very much appreciated.

As for the other problem I have implemented the below fix via RFC2045. But
trimright as John Romedhal suggested should not be used as this removes any
formating characters at the end of the line it should only be removing
spaces and tabs off quoted printables mails.  Basicly your not dealing with
the softline breaks and hard line breaks in the decoding I don't know if
this is because you are doing a trimright but I will check this myself and
let you  know.

Below is a very rough example which maybe incorrect but I have posted in the
message thread TIdMessage Body/Text 2nd posting the raw text to one of the
emails that has this problem, and is a better example than this.

i.e.
{Raw Source Of Email}
This is a email, hope this can help =
you
    1.    hello
    2.    new
    3.    Again

test

{After going through the decode routine and you show the message in a memo
it will look like this - which is wrong - basicly the message is being
displayed on one line}

This is a email, hope this can help you    1.    hello    2.     new    3.
Again Test.

(With my fix in it now shows it as this which is correct)

This is a email, hope this can help
    1.    hello
    2.    new
    3.    Again

Test

I have done some quick dirty modifications of my own to get this to work
with RFC standards.

Have added this code underneath 'Buffer := TrimRight(AIn);' in
'TIdDecoderQuotedPrintable.DecodeToStream(AIn: string; ADest: TStream);'

  // Added By Lee Bambury
  If Length(Buffer) > 0 Then
    begin
      // If No Soft Line Break Then It Is A Hard Line Break
      If Buffer[Length(Buffer)] <> '=' Then
        Buffer := Buffer + EOL;
      {EnDIF}
    end
  Else
    // Blank Line Issue A Hard Line Break
    Buffer := EOL;
  {EndIF}

And have modified 'TIdMessageDecoderMIME.ReadBody(ADestStream: TStream; var
AMsgEnd: Boolean): TIdMessageDecoder;' and remed out the following line at
the bottom of the procedure.

//      Remed Out By Lee Bambury The Following 3 Lines
//      if Length(LLine) > 0 then
//      begin
          LDecoder.DecodeToStream(LLine, ADestStream);
//      end;

Thanks
Inferno

"Don Siders - Team Indy" <side...@att.net> wrote in message
news:3bbd2c49_2@dnews...

Quote

> "John Romedahl" <j...@adr.dk> wrote in message news:3bbcc072$1_2@dnews...

> > I hope Team Indy will follow up on this thread, with a status.

> I don't know if this is what you're hoping for, but here goes...

> > I changed in unit IdMessageClient the function "ProcessTextPart"  - see
> the
> > bottom of this mail - I hope this can help you. - Let me know how it
> goes...

> Your suggestion has been forwarded to the Indy developer(s) that maintain
> the modules in question.  Your change makes perfect sense to me, but then
> again - I just write docs.<g>  I've also suggested that a similar
operation
> may be needed in ProcessAttachment.

> > together with the formatting problems
> > when storing quoted printable.

> Maybe I'm dense... but I still don't understand what (exactly) is broken
in
> the quoted-printable coders.  If someone can  send a specific example of
the
> output you're getting, and what you're expecting, perhaps I can be of more
> assistance.  Right now, I'm not sure what we're looking for.

> I'm looking forward to more info on this problem.

> Thanks for the feedback...

> Don

Re:TIdMessage.Messageparts.Items[i].ContentType


Thanks I will give the code a try.

Inferno

Quote
"John Romedahl" <j...@adr.dk> wrote in message news:3bbcc072$1_2@dnews...
> I agree.

> It's a showstopper to me as well - together with the formatting problems
> when storing quoted printable.

> I hope Team Indy will follow up on this thread, with a status.

> I changed in unit IdMessageClient the function "ProcessTextPart"  - see
the
> bottom of this mail - I hope this can help you. - Let me know how it
goes...

> best regards
> John Romedahl

> ***************************

> function ProcessTextPart(ADecoder: TIdMessageDecoder): TIdMessageDecoder;
>  var
>     LDestStream: TStringStream;
> begin
>     LDestStream := TStringStream.Create('');
>     try
>       Result := ADecoder.ReadBody(LDestStream, MsgEnd);
>       with TIdText.Create(AMsg.MessageParts) do
>       begin
>         Body.Text := LDestStream.DataString;
>         Headers.AddStdValues(ADecoder.Headers); // << added this line
>       end;
>     finally
>       ADecoder.Free;
>       FreeAndNil(LDestStream);
>     end;
>   end;

Re:TIdMessage.Messageparts.Items[i].ContentType


Just tryed it, Access violates straight away when going into the procedure.

Inferno

Quote
"Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message

news:3bbd76df_2@dnews...
Quote
> Thanks I will give the code a try.

> Inferno

> "John Romedahl" <j...@adr.dk> wrote in message news:3bbcc072$1_2@dnews...
> > I agree.

> > It's a showstopper to me as well - together with the formatting problems
> > when storing quoted printable.

> > I hope Team Indy will follow up on this thread, with a status.

> > I changed in unit IdMessageClient the function "ProcessTextPart"  - see
> the
> > bottom of this mail - I hope this can help you. - Let me know how it
> goes...

> > best regards
> > John Romedahl

> > ***************************

> > function ProcessTextPart(ADecoder: TIdMessageDecoder):
TIdMessageDecoder;
> >  var
> >     LDestStream: TStringStream;
> > begin
> >     LDestStream := TStringStream.Create('');
> >     try
> >       Result := ADecoder.ReadBody(LDestStream, MsgEnd);
> >       with TIdText.Create(AMsg.MessageParts) do
> >       begin
> >         Body.Text := LDestStream.DataString;
> >         Headers.AddStdValues(ADecoder.Headers); // << added this line
> >       end;
> >     finally
> >       ADecoder.Free;
> >       FreeAndNil(LDestStream);
> >     end;
> >   end;

Re:TIdMessage.Messageparts.Items[i].ContentType


ADecoder.Headers is Nil;

Inferno

Quote
"Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message

news:3bbd7796_2@dnews...
Quote
> Just tryed it, Access violates straight away when going into the
procedure.

> Inferno

> "Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message
> news:3bbd76df_2@dnews...
> > Thanks I will give the code a try.

> > Inferno

> > "John Romedahl" <j...@adr.dk> wrote in message

news:3bbcc072$1_2@dnews...
Quote
> > > I agree.

> > > It's a showstopper to me as well - together with the formatting
problems
> > > when storing quoted printable.

> > > I hope Team Indy will follow up on this thread, with a status.

> > > I changed in unit IdMessageClient the function "ProcessTextPart"  -
see
> > the
> > > bottom of this mail - I hope this can help you. - Let me know how it
> > goes...

> > > best regards
> > > John Romedahl

> > > ***************************

> > > function ProcessTextPart(ADecoder: TIdMessageDecoder):
> TIdMessageDecoder;
> > >  var
> > >     LDestStream: TStringStream;
> > > begin
> > >     LDestStream := TStringStream.Create('');
> > >     try
> > >       Result := ADecoder.ReadBody(LDestStream, MsgEnd);
> > >       with TIdText.Create(AMsg.MessageParts) do
> > >       begin
> > >         Body.Text := LDestStream.DataString;
> > >         Headers.AddStdValues(ADecoder.Headers); // << added this line
> > >       end;
> > >     finally
> > >       ADecoder.Free;
> > >       FreeAndNil(LDestStream);
> > >     end;
> > >   end;

Re:TIdMessage.Messageparts.Items[i].ContentType


This is because you need to call the equivilant of this function for headers

      Result := ADecoder.ReadBody(LDestStream, MsgEnd);

And there is a function ADecode.ReadHead but the function is empty so it's
obviously something that was never implemented

Inferno

Quote
"Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message

news:3bbd7890_1@dnews...
Quote
> ADecoder.Headers is Nil;

> Inferno

> "Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message
> news:3bbd7796_2@dnews...
> > Just tryed it, Access violates straight away when going into the
> procedure.

> > Inferno

> > "Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message
> > news:3bbd76df_2@dnews...
> > > Thanks I will give the code a try.

> > > Inferno

> > > "John Romedahl" <j...@adr.dk> wrote in message
> news:3bbcc072$1_2@dnews...
> > > > I agree.

> > > > It's a showstopper to me as well - together with the formatting
> problems
> > > > when storing quoted printable.

> > > > I hope Team Indy will follow up on this thread, with a status.

> > > > I changed in unit IdMessageClient the function "ProcessTextPart"  -
> see
> > > the
> > > > bottom of this mail - I hope this can help you. - Let me know how it
> > > goes...

> > > > best regards
> > > > John Romedahl

> > > > ***************************

> > > > function ProcessTextPart(ADecoder: TIdMessageDecoder):
> > TIdMessageDecoder;
> > > >  var
> > > >     LDestStream: TStringStream;
> > > > begin
> > > >     LDestStream := TStringStream.Create('');
> > > >     try
> > > >       Result := ADecoder.ReadBody(LDestStream, MsgEnd);
> > > >       with TIdText.Create(AMsg.MessageParts) do
> > > >       begin
> > > >         Body.Text := LDestStream.DataString;
> > > >         Headers.AddStdValues(ADecoder.Headers); // << added this
line
> > > >       end;
> > > >     finally
> > > >       ADecoder.Free;
> > > >       FreeAndNil(LDestStream);
> > > >     end;
> > > >   end;

Re:TIdMessage.Messageparts.Items[i].ContentType


God Dammit, I forgot to move the Adecode.free sorry John works superbly
thanks for sharing the code your a star that's both problems out of the way
and fixed for me, I hope my patch worked for you I am writing a little
function to remove space and tabs not to replace trimright.

Inferno

Quote
"Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message

news:3bbd7796_2@dnews...
Quote
> Just tryed it, Access violates straight away when going into the
procedure.

> Inferno

> "Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message
> news:3bbd76df_2@dnews...
> > Thanks I will give the code a try.

> > Inferno

> > "John Romedahl" <j...@adr.dk> wrote in message

news:3bbcc072$1_2@dnews...
Quote
> > > I agree.

> > > It's a showstopper to me as well - together with the formatting
problems
> > > when storing quoted printable.

> > > I hope Team Indy will follow up on this thread, with a status.

> > > I changed in unit IdMessageClient the function "ProcessTextPart"  -
see
> > the
> > > bottom of this mail - I hope this can help you. - Let me know how it
> > goes...

> > > best regards
> > > John Romedahl

> > > ***************************

> > > function ProcessTextPart(ADecoder: TIdMessageDecoder):
> TIdMessageDecoder;
> > >  var
> > >     LDestStream: TStringStream;
> > > begin
> > >     LDestStream := TStringStream.Create('');
> > >     try
> > >       Result := ADecoder.ReadBody(LDestStream, MsgEnd);
> > >       with TIdText.Create(AMsg.MessageParts) do
> > >       begin
> > >         Body.Text := LDestStream.DataString;
> > >         Headers.AddStdValues(ADecoder.Headers); // << added this line
> > >       end;
> > >     finally
> > >       ADecoder.Free;
> > >       FreeAndNil(LDestStream);
> > >     end;
> > >   end;

Re:TIdMessage.Messageparts.Items[i].ContentType


to replace trimright, sorry

Inferno

Quote
"Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message

news:3bbd8836_1@dnews...
Quote
> God Dammit, I forgot to move the Adecode.free sorry John works superbly
> thanks for sharing the code your a star that's both problems out of the
way
> and fixed for me, I hope my patch worked for you I am writing a little
> function to remove space and tabs not to replace trimright.

> Inferno

> "Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message
> news:3bbd7796_2@dnews...
> > Just tryed it, Access violates straight away when going into the
> procedure.

> > Inferno

> > "Lee Bambury" <Lee.Bamb...@Jalco.co.uk> wrote in message
> > news:3bbd76df_2@dnews...
> > > Thanks I will give the code a try.

> > > Inferno

> > > "John Romedahl" <j...@adr.dk> wrote in message
> news:3bbcc072$1_2@dnews...
> > > > I agree.

> > > > It's a showstopper to me as well - together with the formatting
> problems
> > > > when storing quoted printable.

> > > > I hope Team Indy will follow up on this thread, with a status.

> > > > I changed in unit IdMessageClient the function "ProcessTextPart"  -
> see
> > > the
> > > > bottom of this mail - I hope this can help you. - Let me know how it
> > > goes...

> > > > best regards
> > > > John Romedahl

> > > > ***************************

> > > > function ProcessTextPart(ADecoder: TIdMessageDecoder):
> > TIdMessageDecoder;
> > > >  var
> > > >     LDestStream: TStringStream;
> > > > begin
> > > >     LDestStream := TStringStream.Create('');
> > > >     try
> > > >       Result := ADecoder.ReadBody(LDestStream, MsgEnd);
> > > >       with TIdText.Create(AMsg.MessageParts) do
> > > >       begin
> > > >         Body.Text := LDestStream.DataString;
> > > >         Headers.AddStdValues(ADecoder.Headers); // << added this
line
> > > >       end;
> > > >     finally
> > > >       ADecoder.Free;
> > > >       FreeAndNil(LDestStream);
> > > >     end;
> > > >   end;

Re:TIdMessage.Messageparts.Items[i].ContentType


[This followup was posted to borland.public.delphi.internet.winsock and
a copy was sent to the cited author.]

In article <3bbd75ce$1_2@dnews>, Lee.Bamb...@Jalco.co.uk says...

Quote
> Sorry Don siders I accidently replied to you instead of the newgroup I do
> apologise.

> Thanks For forwarding that info on to the developers, very much appreciated.

> As for the other problem I have implemented the below fix via RFC2045. But
> trimright as John Romedhal suggested should not be used as this removes any
> formating characters at the end of the line it should only be removing
> spaces and tabs off quoted printables mails.  Basicly your not dealing with
> the softline breaks and hard line breaks in the decoding I don't know if
> this is because you are doing a trimright but I will check this myself and
> let you  know.

> Below is a very rough example which maybe incorrect but I have posted in the
> message thread TIdMessage Body/Text 2nd posting the raw text to one of the
> emails that has this problem, and is a better example than this.

I did look at your sample that you posted in this thread and it did
output correctly with the current development version.  Here's the
output from my test.

This is a email, hope this can help you
    1.    hello
    2.    new
    3.    Again

test

Quote

My guess is that this might have been fixed with some modifications I
had done since Indy 9.0 build 1.

If you have a better example please send it to me because I could not
find one of the example E-Mails you had posted in the thread you
mentioned.

Thank.
--
Support the anti-Spam amendment - Join at http://www.cauce.org/
J. Peter Mugaas     E-Mail:  oma00...@mail.wvnet.edu
http://wvnvm.wvnet.edu/~oma00215/  ICQ Number:  14297043
Finger for PGP Key

Re:TIdMessage.Messageparts.Items[i].ContentType


Quote
> My guess is that this might have been fixed with some modifications I
> had done since Indy 9.0 build 1.

I'm using the sources from the ftp-access
(ftp://indy81:ind...@ftp.nevrona.com/)

the file IdCoderQuotedPrintable.pas is dated 17. September 2001, 07:51

Quote
> If you have a better example please send it to me because I could not
> find one of the example E-Mails you had posted in the thread you
> mentioned.

 I'll mail an example to you later this evening

best regards
John Romedahl

Re:TIdMessage.Messageparts.Items[i].ContentType


I've sent you a mail with the source of a testmail. The result of parsing
that mail is
"This is a testmailThis is line 2The next line is blankThis is line 5  this
line is indent 2 spaceand this one ends on 3 spaces   end of testmail"

best regards
John Romedahl

"J. Peter Mugaas" <oma00...@mail.wvnet.edu> wrote in message
news:MPG.162a2d11a426e8f598970d@forums.borland.com...

Quote
> [This followup was posted to borland.public.delphi.internet.winsock and
> a copy was sent to the cited author.]

> In article <3bbd75ce$1_2@dnews>, Lee.Bamb...@Jalco.co.uk says...
> > Sorry Don siders I accidently replied to you instead of the newgroup I
do
> > apologise.

> > Thanks For forwarding that info on to the developers, very much
appreciated.

> > As for the other problem I have implemented the below fix via RFC2045.
But
> > trimright as John Romedhal suggested should not be used as this removes
any
> > formating characters at the end of the line it should only be removing
> > spaces and tabs off quoted printables mails.  Basicly your not dealing
with
> > the softline breaks and hard line breaks in the decoding I don't know if
> > this is because you are doing a trimright but I will check this myself
and
> > let you  know.

> > Below is a very rough example which maybe incorrect but I have posted in
the
> > message thread TIdMessage Body/Text 2nd posting the raw text to one of
the
> > emails that has this problem, and is a better example than this.

> I did look at your sample that you posted in this thread and it did
> output correctly with the current development version.  Here's the
> output from my test.

> This is a email, hope this can help you
>     1.    hello
>     2.    new
>     3.    Again

> test

> My guess is that this might have been fixed with some modifications I
> had done since Indy 9.0 build 1.

> If you have a better example please send it to me because I could not
> find one of the example E-Mails you had posted in the thread you
> mentioned.

> Thank.
> --
> Support the anti-Spam amendment - Join at http://www.cauce.org/
> J. Peter Mugaas     E-Mail:  oma00...@mail.wvnet.edu
> http://wvnvm.wvnet.edu/~oma00215/  ICQ Number:  14297043
> Finger for PGP Key

Re:TIdMessage.Messageparts.Items[i].ContentType


[This followup was posted to borland.public.delphi.internet.winsock and
a copy was sent to the cited author.]

In article <3bc09d12_2@dnews>, j...@adr.dk says...

Quote
> > My guess is that this might have been fixed with some modifications I
> > had done since Indy 9.0 build 1.

> I'm using the sources from the ftp-access
> (ftp://indy81:ind...@ftp.nevrona.com/)

> the file IdCoderQuotedPrintable.pas is dated 17. September 2001, 07:51

> > If you have a better example please send it to me because I could not
> > find one of the example E-Mails you had posted in the thread you
> > mentioned.

>  I'll mail an example to you later this evening

Okay.  I did get a test message and made some further modifications so
you probably should update the code from the FTP site.  

Anyway, the issue you were complaining about was really two problems and
I think I fixed them.

The first problem was an EOL at the end of the string passed to the
decoder was dropped as well an encoded space (=20).  That has been
fixed.

The second issue was that the MIME Message decoder was not passing an
EOL to the decoder in the first place.  I have gone ahead and fixed that
problem.
--
Support the anti-Spam amendment - Join at http://www.cauce.org/
J. Peter Mugaas     E-Mail:  oma00...@mail.wvnet.edu
http://wvnvm.wvnet.edu/~oma00215/  ICQ Number:  14297043
Finger for PGP Key

Other Threads