Access GetMailWasSent

delphi package - automated exception handling
Post Reply
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Access GetMailWasSent

Post by FredS »

Ported for clarity from viewtopic.php?f=4&t=28780#p53268

My mes file contains:

Code: Select all

AutomaticallySaveBugReport=1
AutoSaveBugReportIfNotSent=1
There are a couple of reasons to get at GetMailWasSent, which is available in IMEExceptionEx. This is not possible without copying the interface. The solution I suggest is adding a method like 'WasMailSent'.

1) Using SendBugReport
When you send a report without the Full Exception Dialog using 'SendBugReport' the Report is Not Auto-saved on send failure.
If I use the only exposed method 'AutoSaveBugReport' then its saved regardless of the send failure.

For now, since I made source changes, I added an accessible method that can be checked :

Code: Select all

    function WasMailSent(const ime: IMEException): Boolean;
    begin
      Result := (ime  as IMEExceptionEx).GetMailWasSent;
    end;
I see no way other than copying the IMEExceptionEx interface to get access to this information.
Here is an example of sending a report without the use of an Exception Dialog:

Code: Select all

    exceptIntf.SendBugReport(Application.MainFormHandle);
    if not madExcept.WasMailSent(exceptIntf) then
      madExcept.AutoSaveBugReport(exceptIntf.BugReport);
    Handled := True;
2) If mail was sent via ImportBugReport.Show
If you load a Report with 'ImportBugReport' and the user sends it during 'Show', it doesn't get automatically deleted.

In this code I need to know if the Report was Sent, and use 'WasMailSent':

Code: Select all

class procedure TMadMBR.ShowMBR(const BugReport: TFilename; SkipDialog: boolean);
var ime : IMEException;
begin
  ime := ImportBugReport(TFile.ReadAllText(BugReport));
  ime.AutoShowBugReport := SkipDialog;
  ime.SetShowBtnVisible(not ime.AutoShowBugReport);
  ime.SetRestartBtnVisible(False);
  ime.SetCloseBtnVisible(False);
  ime.BugReportFile := ExtractFileName(BugReport) + '.txt';// user may want to save it to another location
  ime.Show;
  if madExcept.WasMailSent(ime) then
    TFile.Delete(BugReport);
end;
Post Reply