unit WOEMailClient;
interface
uses
SysUtils, Classes, IdIMAP4, dialogs;
type
TWOEMailClient = class(TComponent)
private
vIdIMAP4: TIdIMAP4;
vUsername: String;
vPassword: String;
vServerIP: String;
vPort: Integer;
vOnConnected: TNotifyEvent;
vOnDisconnected: TNotifyEvent;
vTotalMsgs: LongInt;
{ Private declarations }
protected
{ Protected declarations }
public
procedure Connect;
procedure Disconnect;
function Connected: Boolean;
procedure MailBox(ChooseMailBox: String);
function Messages: LongInt;
constructor Create(aOwner: TComponent); override;
destructor Destroy; override;
{ Public declarations }
published
property Username: string read vUsername write vUsername;
property Password: string read vPassword write vPassword;
property ServerIP: string read vServerIP write vServerIP;
property Port: Integer read vPort write vPort default 143;
property OnConnected: TNotifyEvent read vOnConnected write vOnConnected;
property OnDisconnected: TNotifyEvent read vOnDisconnected write vOnDisconnected;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('War Office (new)', [TWOEMailClient]);
end;
constructor TWOEMailClient.Create(aOwner: TComponent);
begin
inherited Create(aOwner);
vIdIMAP4:= TIdIMAP4.Create(nil);
vPort:= 143;
//bl bla
end;
destructor TWOEMailClient.Destroy;
begin
//bla bla
if vIdIMAP4.Connected then
vIdIMAP4.Disconnect;
inherited Destroy;
end;
procedure TWOEMailClient.Connect;
begin
vidimap4.Port := vport;
vidimap4.Username := vusername;
vidimap4.Password := vpassword;
vidimap4.Host := vServerIP;
vidimap4.Connect;
end;
function TWOEMailClient.Connected: Boolean;
begin
result:= vidimap4.Connected;
end;
procedure TWOEMailClient.Disconnect;
begin
if vidimap4.Connected then
begin
vidimap4.Disconnect;
showmessage('Verbindung abgebrochen'); //nur zu test zwecken
end;
end;
procedure TWOEMailClient.Mailbox(ChooseMailBox: String);
begin
vidimap4.SelectMailBox(ChooseMailBox);
end;
function TWOEMailClient.Messages: LongInt;
begin
result := vidimap4.MailBox.TotalMsgs;
end;
end.