如何在Delphi中使用Outlook与其他电子邮件客户端不同? [英] How is working with Outlook in Delphi different than other email clients?
问题描述
当电子邮件客户端是Thunderbird或Outlook Express时,一切都会很好,但是当Outlook(2007)更为陌生。例如,焦点转移到Outlook,但用户无法关闭Outlook窗口,有时用户甚至无法在程序中使用鼠标 - 箭头在Outlook中消失。我发现自己不得不从任务管理器关闭应用程序。
从我的新手的角度来看,问题是控制表单之一,而不仅限于连接到简单或扩展映射;在这种情况下,后者似乎无关紧要。
有谁知道这里发生了什么?我应该如何更改我的代码来处理这个问题?
这是代码:
MapiMail1:= TMapiMail.Create (自);
try
MapiMail1.Recipients.Add(MainGrid.AllCells [aCol,aRow]);
MapiMail1.Subject:='';
MapiMail1.Body:='';
MapiMail1.EditDialog:= True;
MapiMail1.Send;
finally
MapiMail1.Free;
结束
Outlook使用OLE而不是MAPI工作得很好。尝试这样:
使用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');
除了
Outlook:= CreateOleObject('Outlook.Application');
结束
try
Stringlist:= TStringList.Create;
MailItem:= Outlook.CreateItem(olMailItem);
MailItem.Subject:='subject here';
MailItem.Recipients.Add(isomeone@yahoo.com');
MailItem.Attachments.Add('c:\boot.ini');
Stringlist:= TStringList.Create;
StringList.Add('body here');
MailItem.Body:= StringList.text;
MailInspector:= MailItem.GetInspector;
MailInspector.display(true); // true表示模态
finally
Outlook:=未分配;
StringList.Free;
结束
结束
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;
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('someone@yahoo.com');
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;
这篇关于如何在Delphi中使用Outlook与其他电子邮件客户端不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!