Page 1 of 1

Email in Blazor WASM (WebAssembly) for viewer

Posted: Fri Nov 07, 2025 2:50 am
by Vincent Yeoh
Hi,

I'm working on a Blazor WebAssembly project and have a ReportPreview Razor page that uses the built-in Stimulsoft viewer. I’d like to use the viewer’s Send Email button to allow users to email exported reports.

However, for security reasons, I want the actual email sending (SMTP credentials, etc.) to be handled server-side, not from the client.

My question is:
Can I use the OnEmailReport event to intercept the email request and pass the exported report along with the email settings set by the user to a Blazor method, which then calls a server-side API to send the email? Or is this event strictly client-side, requiring me to write custom JS to handle the export and server call manually?

Any guidance or examples would be helpful.

Thanks.

Re: Email in Blazor WASM (WebAssembly) for viewer

Posted: Mon Nov 10, 2025 6:54 am
by Max Shamanov
Hello.

We would need more time to get an answer for you.
We will let you know when we get any results.

Thank you.

Re: Email in Blazor WASM (WebAssembly) for viewer

Posted: Mon Nov 10, 2025 7:13 am
by Max Shamanov
Hello,

For Blazor Server, the code for working with email is on the server side, but as you wrote, for Blazor Wasm it will be executed on the client side.
We will try to prepare an example for you on how to use JavaScript to intercept the email sending event, which will contain the necessary data: the report name, the exported report, and the submission form data.
You can use this data to implement the method on the server side.

Thank you.
#18757

Re: Email in Blazor WASM (WebAssembly) for viewer

Posted: Mon Nov 17, 2025 10:39 am
by Max Shamanov
Hello,

You could try using this code:

Code: Select all

    private async void OnEmailReport(StiEmailReportEventArgs args)
    {
        var stream = new MemoryStream();
        args.Report.ExportDocument(StiExportFormat.Pdf, stream);
        stream.Seek(0, SeekOrigin.Begin);

        // You can send the stream as an email attachment here.
        // ...

        // Prevent default email sending behavior
        args.Report = null;
    }
In this case, the message ‘Report not specified’ may appear.
This will be fixed in the next version.

In the next version, built-in email sending can be disabled with a new option in the arguments:

Code: Select all

 private async void OnEmailReport(StiEmailReportEventArgs args)
    {
        //var stream = new MemoryStream();
        //args.Report.ExportDocument(StiExportFormat.Pdf, stream);
        //stream.Seek(0, SeekOrigin.Begin);

        // You can send the stream as an email attachment here.
        // ...

        // Prevent default email sending behavior
        args.PreventDefault = true;
    }
Thank you.