Re: TIdMessage.Body is NULL

Giganews Newsgroups
Subject: Re: TIdMessage.Body is NULL
Posted by:  Remy Lebeau (TeamB) (
Date: Thu, 16 Jun 2005

"eduardo" <eduardo.ju…> wrote in message

>                if (IdMensaje->Body->Text != "")
>                    stMensaje= IdMensaje->Body->Text;

That is not the proper way to handle the Body.  You should be checking the
MessageParts->Count before even touching the Body, not afterwards, ie:

    if( IdMensaje->MessageParts->Count > 0 )
        for(int p = IdMensaje->MessageParts->Count-1; p >= 0; --p)
            TIdText *txt = dynamic_cast <TIdText
            if( (txt) && (txt->ContentType == "A Format You Know How To
Process" ) )
                stMensaje = txt->Body->Text;
        stMensaje = IdMensaje->Body->Text;

> IdMensaje->MessageParts->Count is 0 because the is a text/plain, I think.

What is the actual value of the TIdMessage::ContentType property?  It is
unlikely (but not impossible) that both TIdMessage::MessageParts::Count and
TIdMessage::Body::Count would both be 0, unless the message really is empty
to begin with.  What does the raw message data actually look like?



In response to

TIdMessage.Body is NULL posted by eduardo on Thu, 16 Jun 2005