BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: For Indy Team - About TIdPOP3

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
fabianse
Guest





PostPosted: Tue Dec 07, 2004 3:19 pm    Post subject: Re: For Indy Team - About TIdPOP3 Reply with quote



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





PostPosted: Tue Dec 07, 2004 3:19 pm    Post subject: Re: For Indy Team - About TIdPOP3 Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.