Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
- IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdPOP3,
- IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL;
- type
- TForm1 = class(TForm)
- POP3: TIdPOP3;
- Button1: TButton;
- SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
- Memo1: TMemo;
- procedure Button1Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- uses
- IdMessage, IdText;
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- var
- lMsg: TIdMessage;
- liCount: Integer;
- liMessages: Integer;
- begin
- POP3.Connect;
- liMessages := POP3.CheckMessages;
- Memo1.Lines.Add('CheckMessages: ' + IntToSTr(liMessages));
- lMsg := TIdMessage.Create;
- try
- POP3.Retrieve(1, lMsg);
- Memo1.Lines.Text := lMsg.MsgId;
- for liCount := 0 to lMsg.MessageParts.Count-1 do
- if lMsg.MessageParts[liCount] is TIdText then
- Memo1.Lines.AddStrings((lMsg.MessageParts[liCount] as TIdText).Body);
- finally
- lMsg.Free;
- end;
- end;
- end.
- object Form1: TForm1
- Left = 192
- Top = 114
- Width = 696
- Height = 480
- Caption = 'Form1'
- Color = clBtnFace
- Font.Charset = DEFAULT_CHARSET
- Font.Color = clWindowText
- Font.Height = -11
- Font.Name = 'MS Sans Serif'
- Font.Style = []
- OldCreateOrder = False
- PixelsPerInch = 96
- TextHeight = 13
- object Button1: TButton
- Left = 216
- Top = 16
- Width = 75
- Height = 25
- Caption = 'Button1'
- TabOrder = 0
- OnClick = Button1Click
- end
- object Memo1: TMemo
- Left = 24
- Top = 56
- Width = 657
- Height = 185
- Lines.Strings = (
- 'Memo1')
- TabOrder = 1
- end
- object POP3: TIdPOP3
- IOHandler = SSLHandler
- AutoLogin = True
- Host = 'pop.gmail.com'
- Username = 'YourName@gmail.com'
- UseTLS = utUseImplicitTLS
- Password = 'YourPassword'
- Port = 995
- SASLMechanisms = <>
- Left = 40
- Top = 16
- end
- object SSLHandler: TIdSSLIOHandlerSocketOpenSSL
- Destination = 'pop.gmail.com:995'
- Host = 'pop.gmail.com'
- MaxLineAction = maException
- Port = 995
- DefaultPort = 0
- SSLOptions.Method = sslvSSLv3
- SSLOptions.Mode = sslmUnassigned
- SSLOptions.VerifyMode = []
- SSLOptions.VerifyDepth = 0
- Left = 80
- Top = 16
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement