Send mail via application

delphi package - automated exception handling
Post Reply
jsantos98
Posts: 13
Joined: Fri Jun 03, 2005 1:21 am

Send mail via application

Post by jsantos98 »

Hello Mathias,

I was tring to use my own developed exception box, however, I wasn't able to use the new methods like, p.e., SendMapiMail.

The problem is I was trying to find a way to detect if the message was correctly sent and, if not, show a message with the error.

I have seen in the source folder, there is a project for mail API tests which does what I need, but it rewrites the methods and I was trying to avoid that to keep future versions.

Is there a way to use the mail methods like the way I need?


Regards,

Joao
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

The problem is that every string which the end user might see must be customizable. Now if I add dozens of different error messages, I also have to list them in the settings dialog and offer programmers the possibility to translate/customize all those error messages. I'm simply not sure whether that's worth it.
jsantos98
Posts: 13
Joined: Fri Jun 03, 2005 1:21 am

Post by jsantos98 »

Hello,

OK, I'll develop my own email connection.

Thanks for your reply.

Joao
jsantos98
Posts: 13
Joined: Fri Jun 03, 2005 1:21 am

Post by jsantos98 »

Hello Mathias,

While using the code from your Email API Tests, I've come with a problem!

If I try to send a mail using MAPI inside the exception handler, I get an error, while sending it using a normal event handler (button click), it opens the email just fine.

Using Button :
mapi dll opened successfully
mapi reports user abort

Using Exception Handler :
mapi dll opened successfully
mapi reports error


Because the forum doesn't allow attachments, here is the code :

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var a : String;
begin
   Unit_SendMail.SendMapiMail(a, '', '', '');
   Memo1.Text := Memo1.Text + a;
end;

procedure TForm1.MadExceptionHandler1Exception(
  const exceptIntf: IMEException; var handled: Boolean);
var a : String;
begin
   Unit_SendMail.SendMapiMail(a, '', '', '');
   Memo1.Text := Memo1.Text + a;
   Handled := True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   Raise (Exception.Create ('a'));
end;
(The Unit_SendMail.pas file has the SendMapiMail method from MailTest.pas).

Can you reproduce the problem there?

I'm using Delphi 7, Windows XP Pro SP2 and Outlook 2003.


Regards,

Joao
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

No problems here with Outlook Express.

But maybe try it with calling RegisterExceptionHandler directly instead of using the VCL TMadExceptionHandler component. Use "stDontSync" when doing that. Maybe that works better?
jsantos98
Posts: 13
Joined: Fri Jun 03, 2005 1:21 am

Post by jsantos98 »

Hello Madshi,

I've just tested the RegisterExceptionHandler as you have suggested, however, the result is the same!

Any more ideas?


Best regards,

Joao
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Have you tried with stDontSync?

If that doesn't work, either, then I'm out of ideas... :?

As I said, it works with Outlook Express here.
Post Reply