SendInBackground option changes email content

delphi package - automated exception handling

SendInBackground option changes email content

Postby x3mike » Wed Jul 26, 2017 4:19 pm

Hello,

we use an own event handler with a specialized form for displaying bugreports. When the user selects to send the bug report

Code: Select all
procedure ktExceptEventHandler(const exceptIntf: IMEException; var Handled: boolean);
var
...
begin
  if exceptIntf.CrashedThreadId = MainThreadID then
  begin
...
//                 if chkSendReport.Checked then
//                   exceptIntf.SendBugReport;


                 if chkSendReport.Checked then
                 begin
                   exceptIntf.SendInBackground := False;
                   exceptIntf.SendBugReport;
                 end;
...


In the first case (the commented case) the bug report email is composed correctly with the given text and the two attachments (bugreport and screenshot).
But when I set
Code: Select all
exceptIntf.SendInBackground := False;

the composed email has gone and instead of it the bugreport text is used. The screenshot has gone completely.

I would like to await if the email could be sent and then, if this fails provide a special file creation where both file will be stored with a timestamp in its filename:
Code: Select all
                 if chkSendReport.Checked then
                 begin
                   exceptIntf.SendInBackground := False;
                   exceptIntf.SendBugReport;
                   if Supports(exceptIntf, IMEExceptionEx, exceptIntfEx) AND not exceptIntfEx.GetMailWasSent then
                   begin
                     tmpDestPath := HMGetSpecialFolderPath(sfUserDocuments, 'Help And Manual BugReports', true);
                     tmpFileName := IncludeTrailingPathDelimiter(tmpDestPath) + 'bugreport-' + FormatDateTime('yyyymmdd-hhnnss-zzz', Now) + '.txt';
                     tmpImgFileName := IncludeTrailingPathDelimiter(tmpDestPath) + 'bugreport-' + FormatDateTime('yyyymmdd-hhnnss-zzz', Now) + '.png';
                     DebugString(tmpFileName, AnsiString(exceptIntf.BugReport), False, True);
                     exceptIntf.ScreenShot.SavePng(tmpImgFileName);
                     try
                       ShellExecute(0, nil, 'explorer.exe', PChar('/select,'+tmpFileName), nil, SW_SHOWNORMAL);
                     except end;
                   end;
                 end;

This works fine, except of the wrong email content and missing attachments.

Thank you for help!
Best regards,
Michael
x3mike
 
Posts: 6
Joined: Fri Apr 26, 2013 12:50 pm

Re: SendInBackground option changes email content

Postby madshi » Thu Jul 27, 2017 8:16 am

Which email method are you using? I suppose it's MAPI and shellmail/mailto? The exact behaviour of MAPI mailing depends on the locally installed mail client. When using "send in background", madExcept asks the mail client to send the email "hidden". Some mail clients don't like that, for security reasons. If the MAPI interface reports an error, madExcept will use shellmail/sendto instead which doesn't support attachments.

I'd suggest to switch to SMTP client mailing or HTTP uploading, which are more reliable than MAPI/mailto.
madshi
Site Admin
 
Posts: 9408
Joined: Sun Mar 21, 2004 5:25 pm

Re: SendInBackground option changes email content

Postby x3mike » Thu Jul 27, 2017 10:47 am

we use the setting "use local mail client". Both checkboxes "via MAPI" and "via mailto" are checked.

Regards,
Michael
x3mike
 
Posts: 6
Joined: Fri Apr 26, 2013 12:50 pm

Re: SendInBackground option changes email content

Postby x3mike » Tue Aug 01, 2017 6:14 am

Hello,

maybe I have not been clear. When I add the line
Code: Select all
exceptIntf.SendInBackground := False;

before sending the report, the email does not contain any attachment but the bugreport as body. Whithout this line the mail is created with an attachment andn the predefined body text.

Thanks,
Michael
x3mike
 
Posts: 6
Joined: Fri Apr 26, 2013 12:50 pm

Re: SendInBackground option changes email content

Postby madshi » Tue Aug 01, 2017 7:37 am

I fully understood. And I think my first reply was perfectly clear, or was it not? IMHO my first reply not only explained what (probably) happened but also offered a solution. Here it is again:

> The exact behaviour of MAPI mailing depends on the locally installed
> mail client. When using "send in background", madExcept asks the
> mail client to send the email "hidden". Some mail clients don't like
> that, for security reasons. If the MAPI interface reports an error,
> madExcept will use shellmail/sendto instead which doesn't support
> attachments.
> I'd suggest to switch to SMTP client mailing or HTTP uploading,
> which are more reliable than MAPI/mailto.

I don't really know what to add to that right now.
madshi
Site Admin
 
Posts: 9408
Joined: Sun Mar 21, 2004 5:25 pm


Return to madExcept

Who is online

Users browsing this forum: No registered users and 4 guests

cron