JclMapi mapi general failure

ⅰ亾dé卋堺 提交于 2019-12-07 13:21:58

问题


I have the code:

procedure TfrmMain.btnSendClick(Sender: TObject);
var
  aMail: TJclEMail;
begin
  aMail := TJclEMail.Create;
  Screen.Cursor := crHourGlass;
  try
    aMail.Recipients.Add('service@blabla.com');
    aMail.Subject := '[IMPORTANT] blablba';

    aMail.Body := 'text text text text';
    aMail.Send(True);
  finally
    Screen.Cursor := crDefault;
    aMail.Free;
  end;
end;

This throws: MAPI Error: (2) "General MAPI failure" Any idea?

ps: OS Windows 7 Outlook 2010 Delphi 2007


回答1:


I have the same as you, just wrapped inside a class and it is working.

I use to check if MAPI is OK at the first time I execute Send():

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;



回答2:


My problem was that my Jedi library wasnt up to date. I search into jedi repository and JclMapi has change in Tue Dec 27 (Mantis 5748: JclMapi incompatibilities with 64-bit.) Download this changes, re-compile pkg and now works perfectly!

Thank you anyway!!




回答3:


The above code works fine IF email client is not already running.

After struggling with same problem i found that the MAPI client has to run in same user context as the MAPI server (e-mail client - Thunderbird in my case).

However, if calling from an app started with administrator privileges (for example an app running in the debugger) then the MAPI calls would fail with error code 2. If both caller and email client are running as admin then everything works (but who's crazy enough to run e-mail client as admin these days?).



来源:https://stackoverflow.com/questions/14061425/jclmapi-mapi-general-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!