daily pastebin goal
8%
SHARE
TWEET

Untitled

a guest Sep 19th, 2016 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  8.   IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdPOP3,
  9.   IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL;
  10.  
  11. type
  12.   TForm1 = class(TForm)
  13.     POP3: TIdPOP3;
  14.     Button1: TButton;
  15.     SSLHandler: TIdSSLIOHandlerSocketOpenSSL;
  16.     Memo1: TMemo;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.  
  27. implementation
  28.  
  29. uses
  30.   IdMessage, IdText;
  31.  
  32. {$R *.dfm}
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. var
  36.   lMsg: TIdMessage;
  37.   liCount: Integer;
  38.   liMessages: Integer;
  39. begin
  40.   POP3.Connect;
  41.   liMessages := POP3.CheckMessages;
  42.   Memo1.Lines.Add('CheckMessages: ' + IntToSTr(liMessages));
  43.   lMsg := TIdMessage.Create;
  44.   try
  45.     POP3.Retrieve(1, lMsg);
  46.     Memo1.Lines.Text := lMsg.MsgId;
  47.     for liCount := 0 to lMsg.MessageParts.Count-1 do
  48.       if lMsg.MessageParts[liCount] is TIdText then
  49.         Memo1.Lines.AddStrings((lMsg.MessageParts[liCount] as TIdText).Body);
  50.   finally
  51.     lMsg.Free;
  52.   end;
  53. end;
  54.  
  55. end.
  56.    
  57. object Form1: TForm1
  58.   Left = 192
  59.   Top = 114
  60.   Width = 696
  61.   Height = 480
  62.   Caption = 'Form1'
  63.   Color = clBtnFace
  64.   Font.Charset = DEFAULT_CHARSET
  65.   Font.Color = clWindowText
  66.   Font.Height = -11
  67.   Font.Name = 'MS Sans Serif'
  68.   Font.Style = []
  69.   OldCreateOrder = False
  70.   PixelsPerInch = 96
  71.   TextHeight = 13
  72.   object Button1: TButton
  73.     Left = 216
  74.     Top = 16
  75.     Width = 75
  76.     Height = 25
  77.     Caption = 'Button1'
  78.     TabOrder = 0
  79.     OnClick = Button1Click
  80.   end
  81.   object Memo1: TMemo
  82.     Left = 24
  83.     Top = 56
  84.     Width = 657
  85.     Height = 185
  86.     Lines.Strings = (
  87.       'Memo1')
  88.     TabOrder = 1
  89.   end
  90.   object POP3: TIdPOP3
  91.     IOHandler = SSLHandler
  92.     AutoLogin = True
  93.     Host = 'pop.gmail.com'
  94.     Username = 'YourName@gmail.com'
  95.     UseTLS = utUseImplicitTLS
  96.     Password = 'YourPassword'
  97.     Port = 995
  98.     SASLMechanisms = <>
  99.     Left = 40
  100.     Top = 16
  101.   end
  102.   object SSLHandler: TIdSSLIOHandlerSocketOpenSSL
  103.     Destination = 'pop.gmail.com:995'
  104.     Host = 'pop.gmail.com'
  105.     MaxLineAction = maException
  106.     Port = 995
  107.     DefaultPort = 0
  108.     SSLOptions.Method = sslvSSLv3
  109.     SSLOptions.Mode = sslmUnassigned
  110.     SSLOptions.VerifyMode = []
  111.     SSLOptions.VerifyDepth = 0
  112.     Left = 80
  113.     Top = 16
  114.   end
  115. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top