我有代码:
procedure TfrmMain.btnSendClick(Sender: TObject);
var
aMail: TJclEMail;
begin
aMail := TJclEMail.Create;
Screen.Cursor := crHourGlass;
try
aMail.Recipients.Add('[email protected]');
aMail.Subject := '[IMPORTANT] blablba';
aMail.Body := 'text text text text';
aMail.Send(True);
finally
Screen.Cursor := crDefault;
aMail.Free;
end;
end;
抛出:MAPI错误:(2)“常规MAPI故障”
任何的想法?
ps:
操作系统Windows 7
展望2010
德尔福2007
最佳答案
我和你一样,只是包裹在一个类中,它正在工作。
我用来在第一次执行Send()时检查MAPI是否正常:
function TMAPIPrerequisites.IsClientAvailable: Boolean;
var
SimpleMAPI: TJclSimpleMapi;
begin
SimpleMAPI := TJclSimpleMapi.Create;
try
Result := SimpleMAPI.AnyClientInstalled;
finally
SimpleMAPI.Free;
end;
end;
function TMAPIPrerequisites.IsMapiAvailable: Boolean;
var
SimpleMAPI: TJclSimpleMapi;
begin
SimpleMAPI := TJclSimpleMapi.Create;
try
Result := SimpleMAPI.SimpleMapiInstalled;
finally
SimpleMAPI.Free;
end;
end;
关于delphi - JclMapi Mapi一般失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14061425/