如何在 Outlook 中使用 OLE 在前台(而不是后台)显示新的电子邮件表单? [英] How to show on front (and not on background) a new email form in Outlook with OLE?
问题描述
我正在使用 OLE 和 Delphi 从我的 delphi 应用程序到 Outlook 进行通信.
I am using OLE with Delphi to communicate from my delphi app to Outlook.
我正在使用以下代码在 Outlook 中打开新的电子邮件表单.问题是表单在后台,所以如果我生成电子邮件表单的表单最大化,它将覆盖"Outlook 新邮件表单.
I am opening the new email form in Outlook using the following code. The problem is that the form is on background, so if the form from which I am generating the email form is maximized it will "cover" the Outlook new mail form.
如何使该表单出现在顶部?(不是粘在顶部",而是简单地显示在顶部,然后用户可以根据需要将其最小化).
How can I make that form appear it on top? (not "sticking on top", but simply that it appears on top, then a user can mimimize it if they want).
这是代码:
try
OutlookApp := GetActiveOleObject('Outlook.Application');
except
OutlookApp := CreateOleObject('Outlook.Application');
end;
try
MailItem := OutlookApp.CreateItem(olMailItem);
MailItem.To := 'Test@mail.com';
MailItem.Subject := 'This is the subject';
MailItem.HTMLBody := '<HTML>Test</HTML>';
MailItem.Display;
finally
OutlookApp := VarNull;
end;
end;
推荐答案
再添加一个调用:
MailItem.Display;
OutlookApp.ActiveWindow.Activate;
Activate 将 Outlook 带到前台.
Activate brings Outlook to front.
这篇关于如何在 Outlook 中使用 OLE 在前台(而不是后台)显示新的电子邮件表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!