1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdPOP3, IdMessage, StdCtrls;
type TForm1 = class(TForm) NMPOP3: TIdPOP3; IdMessage1: TIdMessage; procedure FormCreate(Sender: TObject); private public end;
type TEmail=record Host,Port,UserName,Password: String; end;
var Form1: TForm1; EMail: array of TEmail; Spam: array of String;
implementation
{$R *.dfm}
function ExtractPath (Path:String) : String; begin Result:=''; while Length(Path)>0 do begin Result:=Result+Copy(Path,1,Pos('\',Path)); if Pos('\',Path)=0 then Path:='';
Delete(Path,1,Pos('\',Path)); end; end;
procedure LoadDates; var TextFile: Text; S: string; A: integer; begin Assign(TextFile,ExtractPath(Application.ExeName)+'MC-Dates.txt'); Reset(TextFile); A:=0; while not EoF(TextFile) do begin SetLength(EMail,A+1); ReadLn(TextFile,S); EMail[A].Host:=Trim( Copy( S, 1,Pos('//',S)-1 ) ); ReadLn(TextFile,S); EMail[A].Port:=Trim( Copy( S, 1,Pos('//',S)-1 ) ); ReadLn(TextFile,S); EMail[A].UserName:=Trim( Copy( S, 1,Pos('//',S)-1 ) ); ReadLn(TextFile,S); EMail[A].Password:=Trim( Copy( S, 1,Pos('//',S)-1 ) ); A:=A+1; end; Close(TextFile);
Assign(TextFile,ExtractPath(Application.ExeName)+'MC-Spam.txt'); Reset(TextFile); A:=0; while not EoF(TextFile) do begin SetLength(Spam,A+1); ReadLn(TextFile,S); Spam[A]:=Trim( Copy( S, 1,Pos('//',S)-1 ) ); A:=A+1; end; Close(TextFile); end;
procedure TForm1.FormCreate(Sender: TObject); var countMails: integer; Deleted: boolean; A,B,C: integer; S,OutPut: string; begin try
OutPut:=''; Application.ShowMainForm:=False; if FileExists(ExtractPath(Application.ExeName)+'MC-Dates.txt') then begin LoadDates; for A:=0 to Length(EMail)-1 do begin S:=''; NMPOP3.Host := EMail[A].Host; NMPOP3.Port := strtoint(EMail[A].Port); NMPOP3.UserName := EMail[A].UserName; NMPOP3.Password := EMail[A].Password; NMPOP3.Connect; countMails := NMPOP3.CheckMessages; for B:= 1 to countMails do begin Deleted:=False; NMPOP3.RetrieveHeader(B, Form1.IdMessage1); for C:= 0 to Length(Spam)-1 do if Pos(Spam[C],ansilowercase(Form1.IdMessage1.From.Text))>0 then if MessageDlg('Spam ('+Form1.IdMessage1.Subject+' von '+Form1.IdMessage1.From.Text+') löschen?',mtInformation,[mbYes,mbNo],0)=mrYes then begin NMPOP3.Delete(B); Deleted:=True; end;
if Deleted=False then
S:=S+' -'+IdMessage1.Subject+' ('+Form1.IdMessage1.From.Text+')'+#13; end;
countMails := NMPOP3.CheckMessages; OutPut:=OutPut+EMail[A].UserName+': '+inttostr(NMPOP3.CheckMessages)+#13; OutPut:=OutPut+S;
NMPOP3.DisConnect; end end else ShowMessage('Datei nicht gefunden: MC-Dates.txt');
if Trim(OutPut)<>'' then ShowMessage(OutPut); except ShowMessage('Es ist ein Fehler bei der Verbindung aufgetreten. Überprüfen Sie Ihre Angaben!'); end;
Application.Terminate; end;
end. |