Re: Get message text only

Giganews Newsgroups
Subject: Re: Get message text only
Posted by:  Remy Lebeau (TeamB) (no.spam@no.spam.com)
Date: Tue, 22 Nov 2005

"Peter S." <pet…@hotmail.com> wrote in message
news:F9392B67C8E2E240pet…@hotmail.com...

> I am very new on indy and I would like some help on how
> to retrieve the text part of a message (content type = text/plain).
> I noticed that
>
> PartType = mptText
>
> returns true for both text/plain and text/html content type.

You need to look at the value of the ContentType, not the PartType.  For
example:

    var
        TextPart: TIdText;

    for I := 0 to IdMessage1.MessageParts.Count-1 do
    begin
        if IdMessage1.MessageParts[I] is TIdText then
        begin
            TextPart := IdMessage1.MessageParts[I] as TIdText;
            if TextPart.ContentType = 'text/plain' then
                // use TextPart as needed...
        end;
    end;

Gambit

Replies

In response to

Get message text only posted by Peter S. on Tue, 22 Nov 2005