1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
-- Simple POP demo, it depends on the mailbox content
with Ada.Text_IO;
with AWS.POP;
procedure POP is
use Ada;
use AWS;
Mailbox : AWS.POP.Mailbox;
M : AWS.POP.Message;
A : AWS.Pop.Attachment;
procedure Display
(M : in AWS.POP.Message;
Index : in Positive;
Quit : in out Boolean) is
begin
Text_IO.Put_Line ("From " & AWS.POP.From (M));
Text_IO.Put_Line ("Subject " & AWS.POP.Subject (M));
end Display;
procedure List_Message is new AWS.POP.For_Every_Message (Display);
procedure List_Message_Header is
new AWS.POP.For_Every_Message_Header (Display);
begin
Mailbox := AWS.POP.Initialize
("host", "username", "password", AWS.POP.Clear_Text);
Text_IO.Put_Line ("M " & Natural'Image (AWS.POP.Message_Count (Mailbox)));
Text_IO.Put_Line ("S " & Natural'Image (AWS.POP.Size (Mailbox)));
M := AWS.POP.Get (Mailbox, 3);
-- A := AWS.POP.Get (M, 2);
-- AWS.POP.Write (A, ".");
Text_IO.Put_Line ("From " & AWS.POP.From (M));
Text_IO.Put_Line ("Subject " & AWS.POP.Subject (M));
Text_IO.Put_Line ("Attachments : " & AWS.POP.Attachment_Count (M)'Img);
Text_IO.New_Line;
Text_IO.Put_Line ("Iterator:");
List_Message (Mailbox, Remove => False);
Text_IO.New_Line;
Text_IO.Put_Line ("Header Iterator:");
List_Message_Header (Mailbox);
AWS.POP.Close (Mailbox);
end POP;
|