mainunit.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:2k
源码类别:

Delphi/CppBuilder

开发平台:

Delphi

  1. unit mainunit;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  5.   Dialogs, StdCtrls, Buttons;
  6. type
  7.   TForm1 = class(TForm)
  8.     Label1: TLabel;
  9.     Edit1: TEdit;
  10.     GroupBox1: TGroupBox;
  11.     Label2: TLabel;
  12.     Label4: TLabel;
  13.     Label3: TLabel;
  14.     Edit4: TEdit;
  15.     Edit2: TEdit;
  16.     Edit3: TEdit;
  17.     BitBtn1: TBitBtn;
  18.     procedure BitBtn1Click(Sender: TObject);
  19.   private
  20.     { Private declarations }
  21.   public
  22.     procedure SplitEmailAddress(EmailAddress:String);
  23.     procedure FillPopnSmtp(SupplierAddress:String);
  24.     { Public declarations }
  25.   end;
  26. var
  27.   Form1: TForm1;
  28. implementation
  29. {$R *.dfm}
  30. Procedure TForm1.SplitEmailAddress(EmailAddress:String);
  31. var
  32.  UserAccountStr:String;//用于保存用户帐号名称
  33.  SupplierStr:String;//用于保存电子邮件服务提供商的地址
  34.  Ptn:Integer;          //保存符号@的位置
  35. begin
  36.  Ptn:=Pos('@',EmailAddress);
  37.  UserAccountStr:=Copy(EmailAddress,1,Ptn-1);
  38.  Edit2.Text:=UserAccountStr;
  39.  SupplierStr:=Copy(EmailAddress,Ptn+1,Length(EmailAddress)-Ptn);
  40.  SupplierStr:=LowerCase(SupplierStr);
  41.  FillPopnSmtp(SupplierStr);
  42. end;
  43. procedure TForm1.FillPopnSmtp(SupplierAddress:String);
  44. var
  45.  PopAndSmtpFile:TextFile;
  46.  TableDir:String;
  47.  TempStr,PopServerAddr,SmtpServerAddr:String;
  48.  Ptn:Integer;
  49. begin
  50.  TableDir:=ExtractFilePath(application.ExeName)+'popnsmtp.txt';
  51.  if FileExists(TableDir) then
  52.   begin
  53.    AssignFile(PopAndSmtpFile,TableDir);
  54.    ReSet(PopAndSmtpFile);
  55.    While Not Eof(PopAndSmtpFile) do
  56.     begin
  57.      Readln(PopAndSmtpFile,TempStr);
  58.      if (Pos(SupplierAddress,TempStr)=1) then
  59.       begin
  60.        Ptn:=Pos('<p>',TempStr);
  61.        Delete(TempStr,1,Ptn+2);
  62.        Ptn:=Pos('<s>',TempStr);
  63.        PopServerAddr:=Copy(TempStr,1,Ptn-1);
  64.        Edit3.Text:=PopServerAddr;
  65.        Delete(TempStr,1,Ptn+2);
  66.        SmtpServerAddr:=TempStr;
  67.        Edit4.Text:=SmtpServerAddr;
  68.        break;
  69.       end;
  70.     end; 
  71.   end;
  72. end;
  73. procedure TForm1.BitBtn1Click(Sender: TObject);
  74. begin
  75.  SplitEmailAddress(Edit1.Text);
  76. end;
  77. end.