• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 613
  • Last Modified:

scanning email inbox with nmpop3 in delphi 6

hi there ,
i am having a problem in automating the pop3 email retrival i need to scan every 10 minutes an email inbox with nmpop3 and get the messages sent from someone and save the attachement file into a directory can anybody help me with this.
0
fadymoussallem
Asked:
fadymoussallem
1 Solution
 
Ray_AdamsCommented:
What problem do you have?
0
 
geobulCommented:
Hi,

Something like :

procedure TForm1.Timer1Timer(Sender: TObject);
var
  i, j: integer;
  fname: string;
begin
  try
    with NMPOP31 do begin
      if not Connected then Connect;
      if MailCount > 0 then begin
        for i := 1 to MailCount do begin
          GetMailMessage(i);
          if MailMessage.Attachments.Count > 0 then begin
            for j := 0 to MailMessage.Attachments.Count - 1 do begin
               fname := ExtractFileName(MailMessage.Attachments[j]);
               CopyFile(PChar(MailMessage.Attachments[j]), PChar('c:\emails\'+ fname), false); // copy a file
            end;
          end;  
        end;
      end;
    end;
  except
    // error
  end;
end;

Regards, Geo
0
 
Eddie ShipmanAll-around developerCommented:
Please, if you have Delphi6, DO NOT use NMPop3. The NetMasters components are notorious
for being buggy and haven;t been updated since 1998. They also do not include sourcecode.
Use Indy (included with D6)  or ICS Instead.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fadymoussallemAuthor Commented:
thank you geobul for your help i am thankful but i am getting always a message fault saying "project raised exception class exception with message "- ERR message 1 has been deleted'
0
 
geobulCommented:
Where are you getting that error? At what line? BTW, I forgot to call Disconnect at the end of the function.
0
 
fadymoussallemAuthor Commented:
thank you very much it worked but i called diconnect at the beginning of the function
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now