📄 frmanalyze.pas
字号:
unit FrmAnalyze;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, OleCtrls, SHDocVw, ImgList,shellapi,
Menus,MailProcessUnit;
type
TFrmAnalyze1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
ListView1: TListView;
Panel3: TPanel;
ImageList1: TImageList;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
SaveDialog1: TSaveDialog;
RichEdit1: TRichEdit;
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure PopupMenu1Popup(Sender: TObject);
private
{ Private declarations }
procedure ShowAttachment(AStr:string);
function DelDirectory(const Source:string): boolean;
public
{ Public declarations }
procedure NowDecodeMail;
end;
var
FrmAnalyze1: TFrmAnalyze1;
implementation
{$R *.dfm}
function TFrmAnalyze1.DelDirectory(const Source:string): boolean;
var
fo: TSHFILEOPSTRUCT;
begin
FillChar(fo, SizeOf(fo), 0);
with fo do
begin
Wnd := 0;
wFunc := FO_DELETE;
pFrom := PChar(source+#0);
pTo := #0#0;
fFlags := FOF_NOCONFIRMATION+FOF_SILENT;
end;
Result := (SHFileOperation(fo) = 0);
end;
procedure TFrmAnalyze1.NowDecodeMail;
var
CoolMailMessage:TCoolMailMessage;
MyPathName: array[0..255] of Char;
MyFilePath,AttRoot,AttPath:string;
i:integer;
MyList:TStringList;
begin
CoolMailMessage:=TCoolMailMessage.Create(nil);
MyList:=TStringList.Create;
try
gettemppath(255, @MyPathName);
MyFilePath:=MyPathName+'\_temp.eml';
AttRoot:=MyPathName+'\attach';
DelDirectory(AttRoot);
AttRoot:=MyPathName+'\attach\';
createdir(AttRoot);
CoolMailMessage.LoadFromFile(MyFilePath);
Edit1.Text:=trim(CoolMailMessage.From);
Edit2.Text:=trim(CoolMailMessage.SendTo.Text);
Edit3.Text:=datetostr(CoolMailMessage.Date)+' '+timetostr(CoolMailMessage.Date);
Edit4.Text:=CoolMailMessage.Subject;
RichEdit1.Text:=CoolMailMessage.MailBody.Text;
if RichEdit1.Lines.Count>1 then
RichEdit1.Lines.Delete(RichEdit1.Lines.Count-1);
for i:=0 to CoolMailMessage.AttFiles.Count-1 do
begin
AttPath:=AttRoot+CoolMailMessage.AttFiles[i].FileName;
CoolMailMessage.AttFiles[i].Decode;
CoolMailMessage.AttFiles[i].SaveContentBodyToFile(AttPath);
MyList.Add(CoolMailMessage.AttFiles[i].FileName);
end;
ShowAttachment(MyList.Text);
finally
CoolMailMessage.Free;
MyList.Free;
end;
end;
procedure TFrmAnalyze1.ShowAttachment(AStr:string);
var
i:integer;
MyList:TStringList;
MyListItem:TListItem;
flag:integer;
info: tshfileinfo;
icon:TIcon;
begin
MyList:=TStringList.Create;
try
MyList.Text:=AStr;
ListView1.clear;
for i:=0 to MyList.Count-1 do
begin
with ListView1 do
begin
Icon := TIcon.Create;
MyListItem:= Items.Add;
MyListItem.Caption:=MyList.Strings[i];
Flag:=(SHGFI_LARGEICON or SHGFI_ICON or SHGFI_USEFILEATTRIBUTES);
SHGetFileInfo(Pchar('1.'+ExtractFileExt(MyList.Strings[i])),0,info,Sizeof(info),Flag);
Icon.Handle :=info.hIcon;
ImageList1.AddIcon(Icon);
MyListItem.ImageIndex:=ImageList1.Count-1;
Icon.Free;
end;
end;
finally
MyList.Free;
end;
end;
procedure TFrmAnalyze1.N1Click(Sender: TObject);
var
MyPathName: array[0..255] of Char;
FTempSavePath:string;
begin
if ListView1.Selected<>nil then
begin
gettemppath(255, @MyPathName);
FTempSavePath:=MyPathName+'attach\'+ListView1.Selected.Caption;
ShellExecute(application.handle,nil,pchar(FTempSavePath),nil,nil,sw_shownormal);
end;
end;
procedure TFrmAnalyze1.N2Click(Sender: TObject);
var
MyPathName: array[0..255] of Char;
FTempSavePath:string;
begin
if ListView1.Selected<>nil then
begin
gettemppath(255, @MyPathName);
FTempSavePath:=MyPathName+'attach\'+ListView1.Selected.Caption;
SaveDialog1.FileName:=ListView1.Selected.Caption;
SaveDialog1.Filter:='*.*|*.*';
if SaveDialog1.Execute then
begin
if fileexists(SaveDialog1.FileName) then
begin
case Application.MessageBox(pchar(SaveDialog1.FileName+ ' 已存在,是否覆盖。'),'提示信息',MB_YESNO or
MB_ICONQUESTION) of
IDNO:exit;
end;
end;
CopyFile(pchar(FTempSavePath),pchar(SaveDialog1.FileName),false);
end;
end;
end;
procedure TFrmAnalyze1.PopupMenu1Popup(Sender: TObject);
begin
if listview1.Selected=nil then
begin
N1.Enabled:=false;
N2.Enabled:=false;
end
else begin
N1.Enabled:=true;
N2.Enabled:=true;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -