was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

20 Visitors Online


 
...E-Mail Adressen von Outlook .dbx extrahieren?
Autor: SennaSpy
[ Tip ausdrucken ]  

Tip Bewertung (7):  
     


unit ExtractEmailsFunc;

interface

uses
  
Windows, SysUtils;

procedure CheckEMail(FilePath: string);

implementation

var
  
BufferSize: Integer;

function VerifyFile(strFileName: string): Integer;
var
  
intErro: Integer;
  tsrFile: TSearchRec;
begin
  
intErro := FindFirst(strFileName, FaAnyFile, tsrFile);
  if intErro = 0 then Result := tsrFile.Size 
  else 
    
Result := -1;
  FindClose(tsrFile);
end;

procedure CheckEMail(FilePath: string);
var
  
I: Integer;
  hFile: Integer;
  Buffer: PChar;
  StrEmail: string;
begin
  
hFile := FileOpen(FilePath, fmOpenRead);
  try
    if 
hFile = 0 then Exit;
    GetMem(Buffer, bufferSize + 1);
    ZeroMemory(Buffer, BufferSize + 1);
    try
      
FileRead(hFile, Buffer^, BufferSize);
      I := 0;
      while I <= BufferSize - 1 do 
      begin
        
StrEmail := '';
        if Buffer[I] = '<' then 
        begin
          
Inc(I);
          while (Buffer[I] <> '@') and (I <= BufferSize) do 
          begin
            if 
(Buffer[I] = CHR(45)) or (Buffer[I] = CHR(46)) or
              
(Buffer[I] = CHR(90)) or ((Buffer[I] > CHR(49)) and (Buffer[I] <= CHR(57)))
              or ((Buffer[I] >= CHR(65)) and (Buffer[I] <= CHR(90))) or
              
((Buffer[I] >= CHR(97)) and (Buffer[I] <= CHR(122))) then 
            begin
              
StrEmail := StrEmail + Buffer[I];
            end 
            else 
            begin
              
StrEmail := '';
              Break;
            end;
            Inc(I);
          end;
          if StrEmail <> '' then 
          begin
            
StrEmail := StrEmail + '@';
            Inc(I);
            while (Buffer[I] <> '.') and (I <= BufferSize) do 
            begin
              if 
(Buffer[I] = CHR(45)) or (Buffer[I] = CHR(46)) or
                
(Buffer[I] = CHR(90)) or ((Buffer[I] >= CHR(49)) and (Buffer[I] <= CHR(57)))
                or ((Buffer[I] >= CHR(65)) and (Buffer[I] <= CHR(90))) or
                
((Buffer[I] >= CHR(97)) and (Buffer[I] <= CHR(122))) then 
              begin
                
StrEmail := StrEmail + Buffer[I];
              end 
              else 
              begin
                
StrEmail := '';
                Break;
              end;
              Inc(I);
            end;
            if StrEmail <> '' then 
            begin
              
StrEmail := StrEmail + '.';
              Inc(i);
              while (Buffer[I] <> '>') and (I <= BufferSize) do 
              begin
                if 
(Buffer[I] = CHR(45)) or (Buffer[I] = CHR(46)) or
                  
(Buffer[I] = CHR(90)) or ((Buffer[I] >= CHR(49)) and (Buffer[I] <= CHR(57)))
                  or ((Buffer[I] >= CHR(65)) and (Buffer[I] <= CHR(90))) or
                  
((Buffer[I] >= CHR(97)) and (Buffer[I] <= CHR(122))) then 
                begin
                  
StrEmail := StrEmail + Buffer[I];
                end 
                else 
                begin
                  
StrEmail := '';
                  Break;
                end;
                Inc(I);
              end;
              if StrEmail <> '' then 
              begin
                
WriteLn(StrEmail);
                Inc(I);
              end;
            end;
          end;
        end 
        else 
          
Inc(I);
      end;
    finally
      
FreeMem(Buffer);
    end;
  finally
    
FileClose(hFile);
  end;
end;

begin
  
BufferSize := VerifyFile(ParamStr(1));
  if BufferSize <= 0 then Exit;
  CheckEMail(ParamStr(1));
end.

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners