如何使用OLE在Outlook(而不是背景)上显示新的电子邮件表单? [英] How to show on front (and not on background) a new email form in Outlook with OLE?

查看:170
本文介绍了如何使用OLE在Outlook(而不是背景)上显示新的电子邮件表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OLE与Delphi从我的delphi应用程序通信到Outlook。



我在Outlook中使用以下代码打开新的电子邮件表单。问题是表单是在背景上,所以如果我生成电子邮件表单的形式被最大化,它将覆盖Outlook新的邮件表单。



如何使表单显示在顶部? (不是粘在上面,但只是它出现在顶部,那么用户可以模仿它,如果他们想要)。



这是代码:

  try 
OutlookApp:= GetActiveOleObject('Outlook.Application');
除了
OutlookApp:= CreateOleObject('Outlook.Application');
结束
try
MailItem:= OutlookApp.CreateItem(olMailItem);
MailItem.To:='Test@mail.com';
MailItem.Subject:='这是主题';
MailItem.HTMLBody:='< HTML> Test< / HTML>';
MailItem.Display;
finally
OutlookApp:= VarNull;
结束
结束


解决方案

只需添加一个电话:

  MailItem.Display; 
OutlookApp.ActiveWindow.Activate;

激活将Outlook带到前面。


I am using OLE with Delphi to communicate from my delphi app to 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).

This is the code:

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;

解决方案

Just add one more call:

MailItem.Display;
OutlookApp.ActiveWindow.Activate;

Activate brings Outlook to front.

这篇关于如何使用OLE在Outlook(而不是背景)上显示新的电子邮件表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆