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.
Email in Blazor WASM (WebAssembly) for viewer
-
Vincent Yeoh
- Posts: 1
- Joined: Fri Nov 07, 2025 2:31 am
-
Max Shamanov
- Posts: 1062
- Joined: Tue Sep 07, 2021 10:11 am
Re: Email in Blazor WASM (WebAssembly) for viewer
Hello.
We would need more time to get an answer for you.
We will let you know when we get any results.
Thank you.
We would need more time to get an answer for you.
We will let you know when we get any results.
Thank you.
-
Max Shamanov
- Posts: 1062
- Joined: Tue Sep 07, 2021 10:11 am
Re: Email in Blazor WASM (WebAssembly) for viewer
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
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
-
Max Shamanov
- Posts: 1062
- Joined: Tue Sep 07, 2021 10:11 am
Re: Email in Blazor WASM (WebAssembly) for viewer
Hello,
You could try using this code:
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:
Thank you.
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;
}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;
}