Re: Receive mail with attachment (indy 9)

Giganews Newsgroups
Subject: Re: Receive mail with attachment (indy 9)
Posted by:  Remy Lebeau \(TeamB\) (no.spam@no.spam.com)
Date: Thu, 27 Mar 2008

"duf" <d…@wp.pl> wrote in message news:032B60F8CD4DE340d…@wp.pl...

> I cannot find code for receive mail with attachment.

Have you looked at the demos on Indy's website yet?

> I try do it with something like this:

Why are you clearing the TIdMessage after downloading it but before
accessing its content?  You need to stop doing that.

> I do not know how can I get name of attachment ( zal_nazwa )
> and how to save file.

You have not read the documentation yet, have you?

    POP3Client->Connect();
    try
    {
        ilosc_wiad = POP3Client->CheckMessages();
        for(int i = 1; i <= ilosc_wiad; ++i)
        {
            IdMessage1->Clear();
            POP3Client->Retrieve(i, IdMessage1);
            for(int j = 0; j < IdMessage1->MessageParts->Count-1; ++j)
            {
                TIdAttachment *Attachment =
dynamic_cast<TIdAttachment*>(IdMessage1->MessageParts->Items[j]);
                if( Attachment )
                {
                    // use Attachment as needed.  It has a FileName
                    // property and SaveToFile() method available...
                }
            }
        }
    }
    __finally
    {
        POP3Client->Disconnect();
    }

Gambit

Replies

In response to

Receive mail with attachment (indy 9) posted by duf on Thu, 27 Mar 2008