 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
fabianse Guest
|
Posted: Tue Dec 07, 2004 3:19 pm Post subject: Re: For Indy Team - About TIdPOP3 |
|
|
Here you have a procedure to read multi part mails, with Indy 9
components, access each part, and save attachments to file.
Before call de procedure, create two components, TIdPOP3 and
TIdMessage, and set de properties of TIdPOP3, host, username, password,
to a valid pop3 account.
Regards
procedure ReadmailAndSaveAttachments(IdPOP31: TIdPop3; IdMessage1:
TIdMessage);
var pop3mailcounttotalI : integer;
var I : integer;
var J : integer;
begin
IdPOP31.Connect;
pop3mailcounttotalI := IdPOP31.CheckMessages;
// browse all mails
for I := 1 to pop3mailcounttotalI do
begin
// get current mail
if IdPOP31.Retrieve( I, IdMessage1 ) then
begin
// browse mail parts
for J := 0 to Pred( IdMessage1.MessageParts.Count ) do
begin
// if the part is an attachment
if ( IdMessage1.MessageParts.Items[ J ] is TIdAttachment) then
begin
// save the attachment to file
if fileexists(TIdAttachment(IdMessage1.MessageParts.Items[J]
).Filename)
then deletefile(TIdAttachment(IdMessage1.MessageParts.Items[J]
).Filename);
TIdAttachment(IdMessage1.MessageParts.Items[J]
).SaveToFile(TIdAttachment(IdMessage1.MessageParts.Items[J]
).Filename);
end;
end;
// delete the message
IdPOP31.Delete(I);
end
else
begin
ShowMessage( 'Could not be retrieved' );
end;
end;
IdPOP31.Disconnect;
end;
|
|
| Back to top |
|
 |
fabianse Guest
|
Posted: Tue Dec 07, 2004 3:19 pm Post subject: Re: For Indy Team - About TIdPOP3 |
|
|
Here you have a procedure to read multi part mails, with Indy 9
components, access each part, and save attachments to file.
Before call de procedure, create two components, TIdPOP3 and
TIdMessage, and set de properties of TIdPOP3, host, username, password,
to a valid pop3 account.
Regards
procedure ReadmailAndSaveAttachments(IdPOP31: TIdPop3; IdMessage1:
TIdMessage);
var pop3mailcounttotalI : integer;
var I : integer;
var J : integer;
begin
IdPOP31.Connect;
pop3mailcounttotalI := IdPOP31.CheckMessages;
// browse all mails
for I := 1 to pop3mailcounttotalI do
begin
// get current mail
if IdPOP31.Retrieve( I, IdMessage1 ) then
begin
// browse mail parts
for J := 0 to Pred( IdMessage1.MessageParts.Count ) do
begin
// if the part is an attachment
if ( IdMessage1.MessageParts.Items[ J ] is TIdAttachment) then
begin
// save the attachment to file
if fileexists(TIdAttachment(IdMessage1.MessageParts.Items[J]
).Filename)
then deletefile(TIdAttachment(IdMessage1.MessageParts.Items[J]
).Filename);
TIdAttachment(IdMessage1.MessageParts.Items[J]
).SaveToFile(TIdAttachment(IdMessage1.MessageParts.Items[J]
).Filename);
end;
end;
// delete the message
IdPOP31.Delete(I);
end
else
begin
ShowMessage( 'Could not be retrieved' );
end;
end;
IdPOP31.Disconnect;
end;
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|