Re: TIdMessage.Body is NULL

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

"eduardo" <eduardo.ju…@ges3000.com> wrote in message
news:24C8CC46EBCEE240eduardo.ju…@ges3000.com...

>                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
*>(IdMensaje->MessageParts->Items[p]);
            if( (txt) && (txt->ContentType == "A Format You Know How To
Process" ) )
            {
                stMensaje = txt->Body->Text;
                break;
            }
        }
    }
    else
        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?

Gambit

Replies

In response to

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