1 | unit Unit1;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | StdCtrls, mimemess, mimepart, ComCtrls;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TForm1 = class(TForm)
|
---|
11 | Edit1: TEdit;
|
---|
12 | Button1: TButton;
|
---|
13 | Label1: TLabel;
|
---|
14 | Memo1: TMemo;
|
---|
15 | Button2: TButton;
|
---|
16 | Label2: TLabel;
|
---|
17 | TreeView1: TTreeView;
|
---|
18 | procedure Button1Click(Sender: TObject);
|
---|
19 | procedure FormCreate(Sender: TObject);
|
---|
20 | procedure FormDestroy(Sender: TObject);
|
---|
21 | procedure Button2Click(Sender: TObject);
|
---|
22 | procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
|
---|
23 | private
|
---|
24 | { Private declarations }
|
---|
25 | procedure AddMimeNode(const parent: TTreeNode; const part: TMimepart);
|
---|
26 | public
|
---|
27 | Mime:TMimemess;
|
---|
28 | { Public declarations }
|
---|
29 | end;
|
---|
30 |
|
---|
31 | var
|
---|
32 | Form1: TForm1;
|
---|
33 |
|
---|
34 | implementation
|
---|
35 |
|
---|
36 | {$R *.DFM}
|
---|
37 |
|
---|
38 | procedure TForm1.AddMimeNode(const parent: TTreeNode; const part: TMimepart);
|
---|
39 | var
|
---|
40 | s: string;
|
---|
41 | node: TTreeNode;
|
---|
42 | n: integer;
|
---|
43 | begin
|
---|
44 | s := format('%-24s %-15s %-s',[part.primary + '/' + part.secondary,part.filename,part.description]);
|
---|
45 | node := TreeView1.Items.AddChild(parent, s);
|
---|
46 | node.Data := part;
|
---|
47 | for n := 0 to part.GetSubPartCount - 1 do
|
---|
48 | AddMimeNode(node, part.getsubpart(n));
|
---|
49 | end;
|
---|
50 |
|
---|
51 | procedure TForm1.Button1Click(Sender: TObject);
|
---|
52 | var
|
---|
53 | n:integer;
|
---|
54 | s:string;
|
---|
55 | begin
|
---|
56 | mime.Clear;
|
---|
57 | memo1.Clear;
|
---|
58 | mime.Lines.LoadFromFile(edit1.text);
|
---|
59 | mime.DecodeMessage;
|
---|
60 | ShowMessage(datetimetostr(mime.Header.Date));
|
---|
61 |
|
---|
62 | Treeview1.Items.Clear;
|
---|
63 | AddMimeNode(nil, mime.MessagePart);
|
---|
64 | Treeview1.FullExpand;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TForm1.FormCreate(Sender: TObject);
|
---|
68 | begin
|
---|
69 | mime:=TMimemess.create;
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TForm1.FormDestroy(Sender: TObject);
|
---|
73 | begin
|
---|
74 | mime.free;
|
---|
75 | end;
|
---|
76 |
|
---|
77 | procedure TForm1.Button2Click(Sender: TObject);
|
---|
78 | var
|
---|
79 | f:string;
|
---|
80 | begin
|
---|
81 | with TMimePart(Treeview1.Selected.data) do
|
---|
82 | begin
|
---|
83 | f:=filename;
|
---|
84 | if f=''
|
---|
85 | then f:='mimedemo.txt';
|
---|
86 | f:='c:/'+f;
|
---|
87 | Decodepart;
|
---|
88 | decodedlines.SaveToFile(f);
|
---|
89 | end;
|
---|
90 | end;
|
---|
91 |
|
---|
92 | procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
|
---|
93 | begin
|
---|
94 | memo1.Lines.assign(TMimepart(Node.Data).Lines);
|
---|
95 | end;
|
---|
96 |
|
---|
97 | end.
|
---|