Mam oto taki problem
Robie w BCB z pomoca pakietu INDY 9 odbieranie maili.
Robie to na podstawie helpa http://www.sprawozdania.info/projekty/apl_internetowe.pdf
W zalaczniku moj caly program http://download.yousendit.com/AEAD34852814D2C9
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "IdPOP3Server"
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{ }
void __fastcall TForm1::parametry()
{
POP3->Host = ComboBox1->Items->Strings[ComboBox1->ItemIndex];
POP3->Port=StrToInt(Edit2->Text);
POP3->Username = Edit1->Text;
POP3->Password = MaskEdit1->Text;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
TStringList *Lista = new TStringList;
if(OpenDialog1->Execute())
Lista->LoadFromFile(OpenDialog1->FileName);
ComboBox1->Items = Lista;
ComboBox2->Items = Lista;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int iloscWiad;
parametry();
if(! POP3->Connected())
{
try
{
StatusBar1->SimpleText="Odbieranie poczty - zestawianie połaczenia...";
POP3->Connect();
StatusBar1->SimpleText="Odbieranie poczty - połaczony";
}
catch (Exception &e)
{
Beep();
StatusBar1->SimpleText="Odbieranie poczty - bład połaczenia";
ShowMessage("Bład połaczenia z serwerem "+ POP3->Host);
}
}
if(POP3->Connected())
{
iloscWiad=POP3->CheckMessages();
POP3->Disconnect();
StatusBar1->SimpleText="Rozłaczony";
if(iloscWiad)
ShowMessage("W Twojej skrzynce jest "+IntToStr(iloscWiad)+" wiadomosci");
else ShowMessage("Brak wiadomosci w skrzynce");
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int iloscWiad, iloscZal,zalaczniki;
TListItem *ListItem;
IdMessage1->Clear();
parametry();
if(! POP3->Connected())
{
try
{
StatusBar1->SimpleText="Odbieranie poczty - zestawianie połaczenia...";
POP3->Connect();
StatusBar1->SimpleText="Odbieranie poczty - połaczony";
}
catch (Exception &e)
{
Beep();
StatusBar1->SimpleText="Odbieranie poczty - bład połaczenia";
ShowMessage("Bład połaczenia z serwerem "+ POP3->Host);
}
}
if(POP3->Connected())
{
iloscWiad=POP3->CheckMessages();
ListView1->Items->Clear();
for(int i=1; i<=iloscWiad; i++)
{
IdMessage1 = new TIdMessage(ListView1);
POP3->Retrieve(i,IdMessage1);
iloscZal = IdMessage1->MessageParts->Count;
ListItem = ListView1->Items->Add();
ListItem->Caption = IdMessage1->From->Address;
ListItem->SubItems->Add(IdMessage1->Subject);
ListItem->SubItems->Add(IdMessage1->Date.DateTimeString());
zalaczniki=0;
for(int j=0; j<iloscZal;j++)
if(IdMessage1->MessageParts->Items[j]->DisplayName=="TIdAttachment")
zalaczniki++;
ListItem->SubItems->Add(IntToStr(zalaczniki));
ListItem->Odebrano =IdMessage1;
}
POP3->Disconnect();
StatusBar1->SimpleText="Rozłaczony";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ListView1SelectItem(TObject *Sender,TListItem *Item, bool Selected)
{
Memo1->Lines->Clear();
if(Selected && Item)
{
ListBox1->Clear();
IdMessage1 = (TIdMessage*)Item->Odebrano;
for(int i=0;i<IdMessage1->MessageParts->Count;i++)
{
if(IdMessage1->MessageParts->Items[i]->DisplayName=="TIdText")
{
TIdText *IdText = (TIdText*)IdMessage1->MessageParts->Items[i];
Memo1->Lines->AddStrings(IdText->Body);
}
if(IdMessage1->MessageParts->Items[i]->DisplayName=="TIdAttachment")
{
TIdAttachment *zal = (TIdAttachment*)IdMessage1->MessageParts->Items[i];
ListBox1->Items->Add(zal->FileName);
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SaveDialog1CanClose(TObject *Sender,
bool &CanClose)
{
int j=0;
for(int i=0;i<IdMessage1->MessageParts->Count;i++)
{
if(IdMessage1->MessageParts->Items[i]->DisplayName=="TIdAttachment")
{
TIdAttachment *zal = (TIdAttachment*)IdMessage1->MessageParts->Items[i];
if(ListBox1->ItemIndex==j) zal->SaveToFile(SaveDialog1->FileName);
j++;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
if(ListBox1->ItemIndex!=-1)
{
SaveDialog1->FileName=ListBox1->Items->Strings[ListBox1->ItemIndex];
SaveDialog1->Execute();
}
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
ktory mi wywala nastaepujacy blad:
[C++ Error] Unit1.cpp(139): E2316 'Odebrano' is not a member of 'TListItem'
[C++ Error] Unit1.cpp(157): E2316 'Odebrano' is not a member of 'TListItem'
[C++ Warning] Unit1.cpp(166): W8004 'IdText' is assigned a value that is never used
[C++ Warning] Unit1.cpp(172): W8004 'zal' is assigned a value that is never used
[C++ Warning] Unit1.cpp(195): W8004 'zal' is assigned a value that is never used
OCzywiscie w tym helpie bylo juz pare błędów z którymi sobie poradziłem.
Dodam ze niejestem programista tylko muszę zrobic taka aplikację i to tyle.
Rozumiem co znaczą te błedy ale nic poza tym.
Prosilbym o konkretny wpis co gdzie poprawić :)
Pozdrawiam.