⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmreadusermail.pas

📁 Mailserver Source code - Delphi. Simple Mail server source code. SMTP and POP3 protocols.
💻 PAS
字号:
unit FrmReadUserMail;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, Grids, DBGrids, ExtCtrls, ImgList, StdCtrls,  Menus, DB, ADODB;

type
  TFrmReadUserMail1 = class(TForm)
    Splitter1: TSplitter;
    Panel1: TPanel;
    Panel2: TPanel;
    ImageList1: TImageList;
    Panel5: TPanel;
    Label1: TLabel;
    ComboBox1: TComboBox;
    Panel3: TPanel;
    Panel4: TPanel;
    ListView1: TListView;
    Panel6: TPanel;
    ComboBox2: TComboBox;
    Label2: TLabel;
    Label3: TLabel;
    Panel7: TPanel;
    Panel8: TPanel;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    DBGrid1: TDBGrid;
    procedure ListView1Click(Sender: TObject);
    procedure ComboBox1Select(Sender: TObject);
    procedure PopupMenu1Popup(Sender: TObject);
    procedure N2Click(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
  private
    { Private declarations }
    FUserID:string;
    procedure ReConfigDBGrid(ATag:integer);
    procedure AddToListview(AStr:string);
    function  GetInfo:string;
    function  GetTotalMailCount:string;
    function  GetTotalMailSize:string;
  public
    { Public declarations }
    procedure IniShow;
  end;

var
  FrmReadUserMail1: TFrmReadUserMail1;

implementation

uses UnitDataModule, UnitConst, FrmAnalyze, FrmStatistics;

{$R *.dfm}
//初始化
procedure TFrmReadUserMail1.IniShow;
begin
  C_SetCombox(UnitDataModule1.GetDomain,ComboBox1);
  ComboBox2.ItemIndex:=0;
  ComboBox1Select(self);
end;

procedure TFrmReadUserMail1.ComboBox1Select(Sender: TObject);
begin
  AddToListview(UnitDataModule1.GetUserListInOneDomain(ComboBox1.Text));
  if listview1.Items.Count>0 then
  begin
    listview1.Selected:=listview1.Items[0];
    ListView1Click(self);
  end;

end;
//刷新listview
procedure TFrmReadUserMail1.AddToListview(AStr:string);
var
  i:integer;
  MyList:TStringList;
  MyListItem:TListItem;
begin
  MyList:=TStringList.Create;
  try
    MyList.text:=AStr;
    listview1.Clear;
    i:=0;
    while i<MyList.Count do
    begin
      MyListItem:=listview1.Items.Add;
      MyListItem.ImageIndex:=0;
      MyListItem.SubItems.Add(MyList.Strings[i]);
      MyListItem.SubItems.Add(MyList.Strings[i+1]);
      i:=i+2;
    end;
  finally
    MyList.free;
  end;
end;


//重新配置DBGrid1---------------------------------------------------------------
procedure TFrmReadUserMail1.ReConfigDBGrid(ATag:integer);
begin
  if ATag=1 then
  begin
    with DBGrid1 do
    begin
      Columns[1].Title.caption:='发信人';
    end;
  end
  else if ATag=2 then
  begin
    with DBGrid1 do
    begin
      Columns[1].Title.caption:='收信人';
    end;
  end;
end;
//------------------------------------------------------------------------------

//选择账号----------------------------------------------------------------------
procedure TFrmReadUserMail1.ListView1Click(Sender: TObject);
begin
  if ListView1.Selected<>nil then
  begin
    //保存用户的账号
    FUserID:=ListView1.Selected.SubItems.Strings[0];
    //--------
    if ComboBox2.ItemIndex<=4 then
    begin
      UnitDataModule1.GetMailInBOX(FUserID,'0',inttostr(ComboBox2.ItemIndex+1));
      ReConfigDBGrid(1);
    end
    else begin
      UnitDataModule1.GetMailInBOX(FUserID,'1',inttostr(ComboBox2.ItemIndex-4));
      ReConfigDBGrid(2);
    end;
  end
  else begin
    FUserID:='';
    DBGrid1.DataSource.DataSet.Close;
  end;
end;
//------------------------------------------------------------------------------


procedure TFrmReadUserMail1.PopupMenu1Popup(Sender: TObject);
begin
  if DBGrid1.DataSource.DataSet.Eof=true then
  begin
    n1.Enabled:=false;
    n2.Enabled:=false;
  end
  else begin
    n1.Enabled:=true;
    n2.Enabled:=true;
  end;
end;

procedure TFrmReadUserMail1.N2Click(Sender: TObject);
begin
  FrmStatistics1.ShowText:=GetInfo;
  FrmStatistics1.ShowModal;
end;

function TFrmReadUserMail1.GetInfo:string;
var
  MyList:TStringList;
begin
  MyList:=TStringList.Create;
  try
    Mylist.Add('所属域名: '+ComboBox1.Text);
    Mylist.Add('');
    Mylist.Add('用户帐号:'+listview1.Selected.SubItems.Strings[0]);
    Mylist.Add('');
    Mylist.Add('邮件状态:'+combobox2.Text);
    Mylist.Add('');
    Mylist.Add('邮件总数:'+GetTotalMailCount);
    Mylist.Add('');
    Mylist.Add('邮件所占的空间:'+GetTotalMailSize);
    Mylist.Add('');

    result:=Mylist.Text;
  finally
    MyList.Free;
  end;
end;

function TFrmReadUserMail1.GetTotalMailCount:string;
begin
    if ComboBox2.ItemIndex<=4 then
    begin
      result:=UnitDataModule1.GetMailCountInBOX(FUserID,'0',inttostr(ComboBox2.ItemIndex+1));
    end
    else begin
      result:=UnitDataModule1.GetMailCountInBOX(FUserID,'1',inttostr(ComboBox2.ItemIndex-4));
    end;
end;

function TFrmReadUserMail1.GetTotalMailSize:string;
begin
  if ComboBox2.ItemIndex<=4 then
  begin
    result:=UnitDataModule1.GetMailTotalSizeInBOX(FUserID,'0',inttostr(ComboBox2.ItemIndex+1))+' byte';;
  end
  else begin
    result:=UnitDataModule1.GetMailTotalSizeInBOX(FUserID,'1',inttostr(ComboBox2.ItemIndex-4))+' byte';;
  end;
end;



procedure TFrmReadUserMail1.DBGrid1DblClick(Sender: TObject);
begin
  try
    screen.Cursor:=crHourGlass;
    with  dbgrid1.DataSource.DataSet do
    begin
      if Eof=false then
      begin
        UnitDataModule1.DCOMConnection1.AppServer.MailID:=fields[0].AsString;
        UnitDataModule1.DCOMConnection1.AppServer.UserMail:=ListView1.Selected.SubItems.Strings[1]+'@'+ComboBox1.Text;
        if ComboBox2.ItemIndex<=4  then
          UnitDataModule1.DCOMConnection1.AppServer.ReplyState:='0'
        else
          UnitDataModule1.DCOMConnection1.AppServer.ReplyState:='1';
        if ComboBox2.ItemIndex=0 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='1'
        else if ComboBox2.ItemIndex=1 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='2'
        else if ComboBox2.ItemIndex=2 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='3'
        else if ComboBox2.ItemIndex=3 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='4'
        else if ComboBox2.ItemIndex=4 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='5'
        else if ComboBox2.ItemIndex=5 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='1'
        else if ComboBox2.ItemIndex=6 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='2'
        else if ComboBox2.ItemIndex=7 then
          UnitDataModule1.DCOMConnection1.AppServer.MailBox:='3';
        C_SaveMailData(UnitDataModule1.DCOMConnection1.AppServer.MailData);
        FrmAnalyze1.NowDecodeMail;
        FrmAnalyze1.ShowModal;
      end;
    end;
  finally
    screen.Cursor:=crDefault;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -