Custom file adding to attachments

delphi package - automated exception handling
Post Reply
ertank
Posts: 10
Joined: Sat Feb 17, 2024 8:42 pm

Custom file adding to attachments

Post by ertank »

Hi,

Is it possible to add a custom file in the exe directory as an attachment?
Exe directory is variable. Not a fixed directory in my case.

Thanks & Regards,
Ertan
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Custom file adding to attachments

Post by madshi »

Yes, you can. In your exception handler, you can use "exceptIntf.AdditionalAttachments.Add()". See here:

http://help.madshi.net/MESettings.htm#IMEAttachments
ertank
Posts: 10
Joined: Sat Feb 17, 2024 8:42 pm

Re: Custom file adding to attachments

Post by ertank »

Can I do same using IDE wizard?
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Custom file adding to attachments

Post by madshi »

Yes, but only with a fixed file path.
ertank
Posts: 10
Joined: Sat Feb 17, 2024 8:42 pm

Re: Custom file adding to attachments

Post by ertank »

madshi wrote: Thu Feb 22, 2024 1:53 pm In your exception handler
Can I use component TApplicationEvents and its OnException event handler for this purpose?
Or, this is an event handler specific to madExcept?
madshi
Site Admin
Posts: 10766
Joined: Sun Mar 21, 2004 5:25 pm

Re: Custom file adding to attachments

Post by madshi »

It's an exception handler specific to madExcept. The code should be pretty simple, something like this:

Code: Select all

uses madExcept;

procedure YourExceptionHandler(const exceptIntf: IMEException; var handled: boolean)
begin
  exceptIntf.AdditionalAttachments.Add(...);  // see documentation
end;

initialization
  RegisterExceptionHandler(YourExceptionHandler, stDontSync);
end.
Please note that "stDontSync" means that the exception handler will be called in the context of a secondary thread, which means you should not do anything in there that isn't thread safe. Specifically, you shouldn't do VCL stuff in there.
Post Reply