IMEException.MailBody

delphi package - automated exception handling
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

IMEException.MailBody

Post by Tahtu »

I want to send my own created bug report via E-Mail.

Doing this, I'm using this code:

Code: Select all

    MEException.MailSubject := 'My subject with the my version number';
    MEException.MailBody := 'My bug report with my information';
    MEException.SendBugReport(Handle);
... the created email contains my subject and your bug report. :confused:

Is this a bug of madExcept? I'm using madExcept 4.0.16, downloaded today.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

The bug report is usually an attachment, isn't it? You've just modified the mail subject and body, but not the attachment(s).

Anyway, in order to give good advice, I'd need to know a bit more about what're trying to do. Is this in reaction to an exception? And you want to run this code inside of an exception handler? In which way is your created bug report different to the one created by madExcept, and why do you want to replace it?
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

madshi wrote:The bug report is usually an attachment, isn't it? You've just modified the mail subject and body, but not the attachment(s).
I want to send the bug report as the body of the mail. This is easier for the user to find out, what he sends to me. Some users does not send a mail, the don't know what they are sending...
madshi wrote:Anyway, in order to give good advice, I'd need to know a bit more about what're trying to do. Is this in reaction to an exception?
Yes, I call this code inside a ExceptionHandler, configured with RegisterExceptionHandler with "stTrySyncCallAlways".
madshi wrote:In which way is your created bug report different to the one created by madExcept, and why do you want to replace it?
I don't need the most parts like Window version, User name, Memory and so on.

The call stack is imho not formated easy to read for me. I like the format from EurekaLog:

Code: Select all

My version 5.4

ERangeError:
Range check error

-----------------------------------------------------
|Module      |Unit    |Function             |Line   |
-----------------------------------------------------
|Project1.exe|MainUnit|TWWindow.Button1Click|790[1] |
|Project1.exe|Project1|initialization       |121[34]|
-----------------------------------------------------
Btw: EurekaLog shows the Unit with ".pas" - and the main program as with ".dpr" and without "initialization" as function.

Additional, I place a log of 10 lines of my separaded thread to the bug report.

Indeed, I can handle this as an attachment, but I don't need your bug report. So I think MEException.MailBody would be a good way to replace your bug report with my bug report. Imho this should be the sense of MEException.MailBody ... analog to the MEException.MailSubject.

So I would be happy, if you would change this.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

No need for me to change it, you can do it by yourself.

In the madExcept settings simply remove the bug report attachment. Then in the exception handler set "exceptIntf.MailBody := yourOwnBugReport". Done.

There's one small problem, though: madExcept calculates the bug report in the background, but already displays the exception box and calls your handlers before the bug report is complete. This is done to make sure the user doesn't have to wait for a reaction in case there's a crash. Practically that means you might want to use "epCompleteReport" as the "phase" when calling RegisterExceptionHandler, to make sure the thread callstacks are all complete.
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

madshi wrote:No need for me to change it, you can do it by yourself.

In the madExcept settings simply remove the bug report attachment. Then in the exception handler set "exceptIntf.MailBody := yourOwnBugReport". Done.
... this is what I try and I reported in this topic - but it does not work. :sorry:

The attachment will be removed, but the body of the opened mail window contains your bug report.

Code: Select all

procedure ExceptionHandler(const MEException: IMEException; var Handled: Boolean);
begin
  [...]
    MEException.GetBugReport();
    MEException.SendInBackground := False;
    MEException.MailSubject := 'My subject';
    MEException.MailBody := 'My bug report';
    MEException.SendBugReport(Application.Handle);
madshi wrote:There's one small problem, though: madExcept calculates the bug report in the background,
I protect this with GetBugReport, like you mentioned in an other topic.

Before I send the bug report, I check, if the user uses the latest update of my program. This check will be done via HTTP. So this takes more time than creating the call stack I think. Additional, I'm using GetBugReport to protect this.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

So which mail body do you receive exactly?
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

Code: Select all

date/time          : 2016-12-07, 23:01:17, 472ms
computer name      : MACBOOK
user name          : Tahtu <admin>
registered owner   : Tahtu
operating system   : Windows 7 x64 Service Pack 1 build 7601
system language    : German
system up time     : 2 hours 25 minutes
program up time    : 4 seconds
processors         : 4x Intel(R) Core(TM) i5-2435M CPU @ 2.40GHz
physical memory    : 1659/4007 MB (free/total)
free disk space    : (C:) 34,58 GB
display mode       : 1280x800, 32 bit
process id         : $16e0
allocated memory   : 41,83 MB
largest free block : 1,48 GB
executable         : Project1.exe
exec. date/time    : 2016-12-07 22:05
version            : 5.4.4.45
compiled with      : Delphi XE2
madExcept version  : 4.0.16
callstack crc      : $1b05f9fe, $354a0ea1, $354a0ea1
exception number   : 1
exception class    : ERangeError
exception message  : Range check error.

main thread ($1498):
0100c9b9 Project1.exe MainUnit 790  +1 TWWindow.Button1Click
01024a4f Project1.exe Project1 121 +34 initialization

thread $1514:
6a48793a gdiplus.dll
Btw: There is a "." (dot) added to the "exception message". I don't like it, since sometimes I have exception messages which contain data. In that case, I have to find out, if the dot comes from my data or from madExcept.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

Which mail sending method are you using?
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

[ ] upload to web server
[ ] send via SMTP
[X] use local mail client
[ ] send bug report in background

[ ] try to contact the mail client via MAPI
[X] try to contact the mail client via mailto


... MAPI doesn't work on my private system.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

Ah, mailto is special because it doesn't support attachments. Try calling the following function (exported by madExcept.pas) directly:

Code: Select all

function SendShellMail (const rcptTo: UnicodeString; const subject, body: UnicodeString) : boolean;
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

Code: Select all

    MEException.MailSubject := 'My mail subject';
    MEException.MailBody := 'My bug report';
//    MEException.SendBugReport(Handle);
    SendShellMail(MEException.MailAddr, MEException.MailSubject, MEException.MailBody);
... with this code, I get what I expect...

But if I understand madExcept well, it tries to send the mail via MAPI - and if it fails, it send it via "mailto" (SendShellMail). So I would be still happy, if you would change madExcept.pas: If the "MailBody" was definded ... it should send this content - not your bug report. :wink:
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

I'll think about it. In the meanwhile you can call this API first:

Code: Select all

function SendMapiMail  (const rcptTo        : UnicodeString;
                        const subject, body : UnicodeString;
                        const attachments   : IMEAttachments = nil;
                              parentWindow  : HWND           = 0;
                              hidden        : boolean        = false;
                              background    : boolean        = false;
                        const settings      : IMESettings    = nil  ) : TExtBool;
If this returns "no", then call SendShellMail() instead. "no" means MAPI mailing isn't available. "other" means the user aborted the mailing operation. "yes" means MAPI mailing (probably) succeeded.
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

Why don't you want to fix the bug of your software?
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: IMEException.MailBody

Post by madshi »

I said I'm going to think about it. It's not as simple as it seems. 99.99% of madExcept users send the bug report as an attachment. But when using mailto/shellmail, attachments are not supported. So in that situation I *have* to send the bug report as the mail body. You suggested to behave differently "If the MailBody was definded", but how can I know if it was defined or not? Your modified MailBody might just be a translation of the original MailBody.

Anyway, I've just had the following idea: If there's no bug report attachment defined, then I don't need to replace the mail body for mailto. I suppose that should fix the issue for you.
Tahtu
Posts: 51
Joined: Thu Sep 06, 2012 12:03 pm

Re: IMEException.MailBody

Post by Tahtu »

madshi wrote:I said I'm going to think about it.
I'm sorry, but I didn't read this. :oops:

Ok, now I understand the problem: You are using SendBugReport to send a mail report. Since SendShellMail does not support attachments, you ignore in this case the content of MailBody. Instead of this, you send your bug report as the body. You think you have to go this way, since SendShellMail does not support attachments.

But this is the wrong way!

If SendShellMail does not support attachments, you can't use it in SendBugReport, since you can't send the attachments on this way.

You are trying to realize something, what it not possible. :crazy:

Indeed it would be nice, if it would possible - but it isn't. :wink:

I don't like attachments, like mentioned before. Right now, you can understand why I don't like them: They are too complicated!

We humans should not try to realize everything - we should try to realize, what it's easy! If something is not eays, we should not realize it. The live would be very much easier for our all, if we would not try too much...

That the same problem like you exception dialog. You are tring to hande that dialog outside the main thread. But because of this, it's not VCL save - so you realized your own implementation. But that implementation does not follow the Windows standards: There are icons on the buttons, die dialog is not DPI aware and there are too many bottons.

... and if I implement my own exception dialog, your dialog is still inside the .exe file.

You are implementing the map file into the exe file. This is great... but the file size increases more than needed. This is bad.

You offer your own setup program. Maybe it look nice. But it does not follow the Windows standards. Because of this, it's not easy to use it for new users. This is bad.

You documentation is fantastic - but it's formated as .html file. Inside Windows, there is a .chm file format for help files. You ignore it. Why?

You are working hard for the support. But it would be better to offer a product, the users don't have to ask something.

Your slogan is "high quality low level programming". I'm sorry, but this it not the truth. You would like to offer high quality - but you are not able to realize it. Go some steps backward - that is the right direction for you... :wink:
Post Reply