📄 loadtblf.pas
字号:
unit LoadTblF;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, DBGrids, ExtCtrls, DBCtrls, Db, DBTables, Mask, ComCtrls;
type
TLoadTableForm = class(TForm)
ContactTable: TTable;
ContactDs: TDataSource;
DBNavigator1: TDBNavigator;
LoadBtn: TButton;
PageControl1: TPageControl;
ListTs: TTabSheet;
DetailsTs: TTabSheet;
DBGrid1: TDBGrid;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label3: TLabel;
DBEdit3: TDBEdit;
Label4: TLabel;
DBMemo1: TDBMemo;
Label5: TLabel;
DBMemo2: TDBMemo;
Label6: TLabel;
DBEdit4: TDBEdit;
Label7: TLabel;
DBEdit5: TDBEdit;
Label8: TLabel;
DBEdit6: TDBEdit;
Label9: TLabel;
DBEdit7: TDBEdit;
procedure LoadBtnClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
LoadTableForm: TLoadTableForm;
implementation
uses ComObj;
{$R *.DFM}
procedure TLoadTableForm.LoadBtnClick(Sender: TObject);
var
OutlookApp,
Mapi,
ContactItems,
CurrentContact: Variant;
begin
{Get the Outlook Application object.}
OutlookApp := CreateOleObject('Outlook.Application');
{Get the MAPI NameSpace object.}
Mapi := OutlookApp.GetNameSpace('MAPI');
{Get the Items collection from the Contacts folder.
Note that if you do not do this FindNext will not work.}
ContactItems := Mapi.Folders('个人文件夹').Folders('联系人').Items;
{Load Contacts into table.}
with ContactTable do
begin
EmptyTable;
Open;
DisableControls;
CurrentContact := ContactItems.Find('[CompanyName] = ' +
QuotedStr('Borland International'));
while not VarIsEmpty(CurrentContact) do
begin
Insert;
FieldByName('EntryId').AsString := CurrentContact.EntryId;
FieldByName('LastName').AsString := CurrentContact.LastName;
FieldByName('FirstName').AsString := CurrentContact.FirstName;
FieldByName('CompanyName').AsString := CurrentContact.CompanyName;
FieldByName('BusAddrStreet').AsString := CurrentContact.BusinessAddressStreet;
FieldByName('BusAddrPOBox').AsString := CurrentContact.BusinessAddressPostOfficeBox;
FieldByName('BusAddrCity').AsString := CurrentContact.BusinessAddressCity;
FieldByName('BusAddrState').AsString := CurrentContact.BusinessAddressState;
FieldByName('BusAddrPostalCode').AsString := CurrentContact.BusinessAddressPostalCode;
FieldByName('BusinessPhone').AsString := CurrentContact.BusinessTelephoneNumber;
Post;
CurrentContact := ContactItems.FindNext;
end; //while
EnableControls;
end; //with
{Close Outlook.}
OutlookApp := Unassigned;
end;
procedure TLoadTableForm.FormCreate(Sender: TObject);
begin
ContactTable.DatabaseName := ExtractFilePath(Application.ExeName);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -