在 Delphi 中使用 Outlook 与其他电子邮件客户端有何不同?

发布于 2024-12-11 01:59:30 字数 655 浏览 5 评论 0原文

我在 Delphi 应用程序中创建一条 mapi 消息,然后用户只需在其默认的 mapi 电子邮件客户端中发送该消息,即格式化的消息出现在其邮件客户端中,然后单击“发送”。

当电子邮件客户端是 Thunderbird 或 Outlook Express 时,一切都运行良好,但当电子邮件客户端是 Outlook (2007) 时,情况就会变得奇怪。例如,焦点转到 Outlook,但用户无法关闭 Outlook 窗口,有时用户甚至无法在程序中使用鼠标 - 箭头在 Outlook 中消失。我发现自己必须从任务管理器关闭该应用程序。

从我的新手角度来看,问题在于控制表单和焦点,而不是与简单或扩展的mapi相关的东西;后者在本例中似乎无关紧要。

有谁知道这是怎么回事?我应该如何更改我的代码来处理这个问题?

这是代码:

MapiMail1 := TMapiMail.Create(self);
try
  MapiMail1.Recipients.Add(MainGrid.AllCells[aCol, aRow]);
  MapiMail1.Subject := '';
  MapiMail1.Body := '';
  MapiMail1.EditDialog := True;
  MapiMail1.Send;
finally
  MapiMail1.Free;
end;

I create a mapi message in my Delphi app, and users then simply send the message in their default mapi email client, i.e. the formatted message appears in their mail client and they click "send."

Everything works great when the email client is Thunderbird or Outlook Express, but things are stranger when it's Outlook (2007). The focus goes to Outlook, for example, but a user can't close the Outlook window, sometimes the user can't even use a mouse within the program--the arrow disappears within Outlook. I find myself having to close the app from Task Manager.

From my newbie perspective, the issue is one of controlling forms and focus more than something connected to simple or extended mapi; the latter seems irrelevant in this case.

Does anyone know what's going on here? And how I should change my code to deal with the issue?

This is the code:

MapiMail1 := TMapiMail.Create(self);
try
  MapiMail1.Recipients.Add(MainGrid.AllCells[aCol, aRow]);
  MapiMail1.Subject := '';
  MapiMail1.Body := '';
  MapiMail1.EditDialog := True;
  MapiMail1.Send;
finally
  MapiMail1.Free;
end;

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

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

发布评论

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

评论(1

盗琴音 2024-12-18 01:59:30

Outlook 使用 OLE 而不是 MAPI 效果很好。试试这个:

USES OleCtrls, ComObj;

procedure TForm1.Button1Click(Sender: TObject);
const
  olMailItem = 0;
var
  Outlook: OLEVariant;
  MailItem: Variant;
  MailInspector : Variant;
  stringlist : TStringList;
begin
  try
   Outlook:=GetActiveOleObject('Outlook.Application') ;
  except
   Outlook:=CreateOleObject('Outlook.Application') ;
  end;
  try
    Stringlist := TStringList.Create;
    MailItem := Outlook.CreateItem(olMailItem) ;
    MailItem.Subject := 'subject here';
    MailItem.Recipients.Add('[email protected]');
    MailItem.Attachments.Add('c:\boot.ini');
    Stringlist := TStringList.Create;
    StringList.Add('body here');
    MailItem.Body := StringList.text;
    MailInspector := MailItem.GetInspector;
    MailInspector.display(true); //true means modal
  finally
    Outlook := Unassigned;
    StringList.Free;
  end;
end;

Outlook works great using OLE rather than MAPI. Try this:

USES OleCtrls, ComObj;

procedure TForm1.Button1Click(Sender: TObject);
const
  olMailItem = 0;
var
  Outlook: OLEVariant;
  MailItem: Variant;
  MailInspector : Variant;
  stringlist : TStringList;
begin
  try
   Outlook:=GetActiveOleObject('Outlook.Application') ;
  except
   Outlook:=CreateOleObject('Outlook.Application') ;
  end;
  try
    Stringlist := TStringList.Create;
    MailItem := Outlook.CreateItem(olMailItem) ;
    MailItem.Subject := 'subject here';
    MailItem.Recipients.Add('[email protected]');
    MailItem.Attachments.Add('c:\boot.ini');
    Stringlist := TStringList.Create;
    StringList.Add('body here');
    MailItem.Body := StringList.text;
    MailInspector := MailItem.GetInspector;
    MailInspector.display(true); //true means modal
  finally
    Outlook := Unassigned;
    StringList.Free;
  end;
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文