home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 November
/
Chip_2002-11_cd1.bin
/
zkuste
/
delphi
/
kompon
/
d3456
/
OUTLTB.ZIP
/
demo
/
Unit1.pas
< prev
Wrap
Pascal/Delphi Source File
|
2002-08-26
|
6KB
|
214 lines
unit Unit1;
{*******************************************************************************
* *
* Outlook Connect - Demo *
*------------------------------------------------------------------------------*
* by Perr Lothar *
* e-mail: lothar.perr@gmx.net *
*------------------------------------------------------------------------------*
* a quick and dirty sample-program ;) *
*******************************************************************************}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, ExtCtrls, OutLookTools, StdCtrls, Menus, Buttons;
type
TForm1 = class(TForm)
Panel2: TPanel;
StringGrid1: TStringGrid;
Panel1: TPanel;
Label1: TLabel;
Panel3: TPanel;
ShowContact: TButton;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
OutlookConnect1: TOutlookConnect;
Button10: TButton;
Button11: TButton;
Button12: TButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure StringGrid1DblClick(Sender: TObject);
procedure ShowContactClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure Fill;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Fill;
var
Counter:Integer;
MyContact:Variant;
begin
StringGrid1.RowCount:=OutlookConnect1.ContactCount+1;
for Counter:=1 to OutlookConnect1.ContactCount do
begin
MyContact:=OutLookConnect1.Contact(Counter);
with StringGrid1 do
begin
Cells[0,Counter]:=IntToStr(Counter);
Cells[1,Counter]:=MyContact.FirstName;
Cells[2,Counter]:=MyContact.LastName;
Cells[3,Counter]:=MyContact.FullName;
Cells[4,Counter]:=MyContact.MobileTelephonenumber;
Cells[5,Counter]:=MyContact.EntryId;
end;
Application.ProcessMessages;
end;
Label1.Caption:=IntToStr(OutlookConnect1.ContactCount)+' Kontakte gefunden';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with StringGrid1 do
begin
Cells[0,0]:='Index';
Cells[1,0]:='FirstName';
Cells[2,0]:='LastName';
Cells[3,0]:='FullName';
Cells[4,0]:='MobileTelephonenumber';
Cells[5,0]:='EntryID';
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
OutlookConnect1.Connected:=true;
end;
procedure TForm1.StringGrid1DblClick(Sender: TObject);
begin
ShowContactClick(Self);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
OutlookConnect1.Calendar.Display;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Fill;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ShowMessage(IntToStr(OutLookConnect1.GetSelectionCount)+' Selectedd Items');
try
ShowMessage(OutLookConnect1.GetSelection(1));
except
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
MyContact:Variant;
begin
MyContact:=OutlookConnect1.CreateContact;
MyContact.FirstName:=Edit1.Text;
MyContact.Save;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
try
OutlookConnect1.FindContact(Edit1.Text).Display;
except
ShowMessage('not found');
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
OutLookConnect1.GetSelection(1).Delete;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
OutlookConnect1.Notes.Display;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
OutlookConnect1.Notes.Items(1).Display;
end;
procedure TForm1.Button9Click(Sender: TObject);
var
MyMail:Variant;
begin
MyMail:=OutlookConnect1.CreateMail('lothar.perr@gmx.net');
MyMail.To:='Lothar.Perr@gmx.net';
MyMail.CC:='cc@gmx.net';
MyMail.BCC:='bcc@gmx.net';
MyMail.Body:='this is the body of the mail';
MyMail.Subject:='test mail';
// OutlookConnect1.AddRecipientToMail(MyMail,'lothar.perr@gmx.net');
// OutlookConnect1.AddAttachmentToMail(MyMail,'c:\autoexec.bat');
MyMail.Display;
// MyMail.Send; // Send the mail (save it in the outbox-folder)
end;
procedure TForm1.Button10Click(Sender: TObject);
var
MyItem:Variant;
begin
ShowMessage( IntToStr(OutlookConnect1.Inbox.items.Count));
MyItem:=OutlookConnect1.Notes.Items.Add;
MyItem.Body:='this is a test from Lothar Perr'+#10#13+
'Line 2';
MyItem.Save;
MyItem.Display;
end;
procedure TForm1.ShowContactClick(Sender: TObject);
begin
OutlookConnect1.ShowContact(StringGrid1.Row);
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
OutlookConnect1.OutlookNameSpace.Folders('Personal Folders').Folders('Contacts').Items(StringGrid1.Row).Display;
end;
procedure TForm1.Button12Click(Sender: TObject);
begin
ShowMessage(OutLookConnect1.CurrentUser);
end;
end.