看看这个有没有用吧:
{***************************************************************
* Unit Name: 获取 Outlook 联系人项目
* Purpose :
* Author : Programme by 七贤工作室 版权所有 www.51google.net
* History :
****************************************************************}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Outlook8, OleServer;
type
TForm1 = class(TForm)
Button1: TButton;
OutlookApplication1: TOutlookApplication;
ContactItem1: TContactItem;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
NmSpace:NameSpace;
ContactsFolder:MAPIFolder;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
OutlookApplication1.Connect;
NmSpace := OutlookApplication1.GetNamespace('MAPI');
NmSpace.Logon('', '', False, False);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
sname,smail:string;
begin
ContactsFolder := NmSpace.GetDefaultFolder(olFolderContacts);
for i:=1 to ContactsFolder.Items.Count do // 显示找到的联系人
begin
sname:=(ContactsFolder.Items.Item(i) as ContactItem).FullName;
smail:=(ContactsFolder.Items.Item(i) as ContactItem).Email1Address;
MessageBox(0,PChar(sname+smail),'找到联系人:',mb_Ok);
end;
if MessageBox(0,'需要打开 Outlook 吗 ?','操作咨询',mb_YesNo) = IDYES then
ContactsFolder.Display; // 打开 Outlook 联系人项目
end;
end.