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

发布于 2024-12-11 09:18:18 字数 138 浏览 0 评论 0原文

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

2010。TIA

I have a Delphi XE app and I'd like to pop up the address book dialog that Outlook uses from within my Delphi app - I assume there are COM classes to support this? What's the best way to get this done? Platform is Win7-64 with Outlook 2010.

TIA

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

聊慰 2024-12-18 09:18:18

免责声明:绝对可以通过 COM 来执行此操作,但 Outlook 将显示第 3 方应用程序正在访问地址簿的警告(理所当然)。如果您想避免这些警告,可以从 Outlook 加载项中运行代码、求助于 MAPI 或使用 Outlook Redemption,它基本上是 MAPI 的高级包装,感觉就像 Outlook 对象模型。

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

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

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;

Disclaimer: It is definitely possible to do so through COM, but Outlook will display warnings that a 3rd party application is accessing the address book (and rightfully so). If you want to avoid these warnings, you can run the code from within an Outlook add-in, resort to MAPI, or use Outlook Redemption, which is basically an advanced wrapper around MAPI that feels like the Outlook Object Model.

The Outlook Object Model offers the SelectNamesDialog dialog to display the address book. It is highly configurable, and you can initialize it with custom sets of addresses as well.

As a little example, here is some code that pops up the address book in multiselect mode. For brevity, it uses late binding (OleVariants). You'll probably want to use early binding in production code.

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;
冷了相思 2024-12-18 09:18:18

要执行此类操作,您需要支持扩展 MAPI 接口。

以下是在 Win7-64 Outlook-2010 上支持此功能的组件的链接。

Easy MAPI

支持执行地址簿对话框。

To do something like this you need to support the Extended MAPI interface.

Here is a link to a component which supports this on Win7-64 Outlook-2010.

Easy MAPI

Supports execution of address book dialogs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文