Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JclMapi mapi general failure

I have the code:

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;

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

ps: OS Windows 7 Outlook 2010 Delphi 2007

like image 854
Agustin Seifert Avatar asked Jul 27 '26 00:07

Agustin Seifert


1 Answers

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;
like image 200
Cesar Romero Avatar answered Jul 28 '26 14:07

Cesar Romero