1
votes

I have a problem that is only happening on Delphi unicode when using JCL (I have made sure to use newest) MAPI code.

I get General MAPI failure

  TmpEmail := TjclEmail.Create;

  TmpResolve := False;
  try
    TmpResolve := TmpEmail.ResolveName(TmpStr_Name, TmpStr_Email, True);
  except
    // new code for Delphi unicode... Also gives mapi failure
  end;
  if TmpResolve then
    TmpEmail.Recipients.Add(TmpStr_Email)
  else
    TmpEmail.Recipients.Add('smtp:' + TmpStr_Email)
  ;
  TmpEmail.Recipients[0].Name := TmpEmail.Recipients[0].Address;

  TmpEmail.Subject := 'bla bla';
  TmpEmail.Send(True);

This code works Delphi 2007, same JCL, Thunderbird, but not when using e.g. Delphi 2010. I have already tried apply what I could of general JCL/MAPI workarounds. Any ideas? :)

1
I think 'smpt:' should be 'smtp:' - mjn
Which MAPI operations fail, ResolveName or Send or both? - mjn
Both ResolveName (immediate) and Send (after quite a few seconds) give error as well... Thanks for the "smpt" catch! (Was some new code I was trying) I just fixed and tested it, but both methods still error! - Tom

1 Answers

3
votes

I had the same problem. In my case the application was running with administrator privileges while the mail client was running under the default windows user context.

Maybe this post can help: JclMapi mapi general failure

See the last Answer. Quote:

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?).