Re. How to save attachment?

Giganews Newsgroups
Subject: Re. How to save attachment?
Posted by:  Elmar Baumann (elmar-nospam@anywhere.net)
Date: Mon, 15 Aug 2005

>Karsten Becker wrote in Article <377C0CEB65D6E240babbelarsch…@hotmail.com>
>with Subject: How to save attachment?, on 15.08.2005 11:26:37
>
>Hi all
>
>I just can't figure out how to save an attachment to disc... I'm getting to

Hello,
an example in Indy9 and BCB6:

TIdAttachment*e;
AnsiString RecievedAttachmentfilename;
int index;

if(Form1->IdMessage1->MessageParts->Count > 0)
{
for (index = 0; index < (Form1->IdMessage1->MessageParts->Count) ;index++)  //Form1->IdMessage1 = your IdMessage-Object
{
  if (dynamic_cast<TIdAttachment*>(Form1->IdMessage1->MessageParts->Items[index]))
  {
  RecievedAttachmentfilename = dynamic_cast<TIdAttachment*>(Form1->IdMessage1->MessageParts->Items[index])->FileName;
  e = dynamic_cast<TIdAttachment*>(Form1->IdMessage1->MessageParts->Items[index]);
  }
}
}

SaveDialog1->FileName = RecievedAttachmentfilename;

if(SaveDialog1->Execute() == IDOK)
{
e->SaveToFile(SaveDialog1->FileName);
}

Regards

Elmar Baumann

------------------------------------------------------------------------------
Indy9 NNTP Internet News Reader/Writer, E. Baumann Software 2005

Portions of this Software are Copyright (c) 1993 - 2005,
Chad Z. Hower (Kudzu) and the Indy Pit Crew
http://www.IndyProject.org/>

Replies

In response to

How to save attachment? posted by Karsten Becker on Mon, 15 Aug 2005