gpt4 book ai didi

delphi - 在 Delphi XE 应用程序 : 中显示 Outlook 通讯簿

转载 作者:行者123 更新时间:2023-12-03 19:34:44 24 4
gpt4 key购买 nike

我有一个 Delphi XE 应用程序,我想从我的 Delphi 应用程序中弹出 Outlook 使用的通讯簿对话框 - 我假设有 COM 类来支持这个?完成这项工作的最佳方法是什么?平台是带有 Outlook 2010 的 Win7-64。

TIA

最佳答案

免责声明:通过 COM 绝对可以做到这一点,但 Outlook 会显示警告,表明 3rd 方应用程序正在访问地址簿(这是理所当然的)。如果您想避免这些警告,您可以从 Outlook 加载项中运行代码、使用 MAPI 或使用 Outlook Redemption ,它基本上是一个围绕 MAPI 的高级包装器,感觉就像 Outlook 对象模型。

Outlook 对象模型提供 SelectNamesDialog对话框以显示通讯簿。它是高度可配置的,您也可以使用自定义地址集对其进行初始化。

作为一个小例子,这里有一些在多选模式下弹出地址簿的代码。为简洁起见,它使用后期绑定(bind)(OleVariants)。您可能希望在生产代码中使用早期绑定(bind)。

procedure TForm1.Button1Click(Sender: TObject);
var
application: OleVariant;
dialog: OleVariant;
i: Integer;
recipients: String;
recipient: OleVariant;

begin
application := createOleObject( 'Outlook.Application' );

// Obtain the dialog
dialog := application.session.getSelectNamesDialog;

// Only show the a single 'add' field, multiselect
dialog.setDefaultDisplayMode( 6 ); // 6 = olDefaultDelegates

// Display the dialog
dialog.display;

// Display selection
recipients := '';
for i := 1 to dialog.recipients.count do
begin
recipient := dialog.recipients.item( i );

recipients := recipients + recipient.name + #13#10;
end;

showMessage( recipients );
end;

关于delphi - 在 Delphi XE 应用程序 : 中显示 Outlook 通讯簿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7870453/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com