This blog post may be helpful to you: Blazor (Wasm) – How to Send Email from a PWA. It invokes the user's native mail application instead of relying on a server-based or API-based implementation.
Excerpted, "...for very basic email needs is to leverage the old-school technique of using “mailto:” anchor links combined with injecting Blazor’s IJSRuntime."
protected void SendLocalEmail(string toEmailAddress, string subject, string body)
{
JsRuntime.InvokeAsync<object>("blazorExtensions.SendLocalEmail",
new object[] { toEmailAddress, subject, body });
}
Then, in your wwwroot folder, you should have a corresponding .js file (i.e. GlobalFunctions.js) that contains the corresponding JavaScript SendLocalEmail() function
window.blazorExtensions = {
SendLocalEmail: function (mailto, subject, body) {
var link = document.createElement('a');
var uri = "mailto:" + mailto + "?";
if (!isEmpty(subject)) {
uri = uri + "subject=" + subject;
}
if (!isEmpty(body)) {
if (!isEmpty(subject)) { // We already appended one querystring parameter, add the '&' separator
uri = uri + "&"
}
uri = uri + "body=" + body;
}
uri = encodeURI(uri);
uri = uri.substring(0, 2000); // Avoid exceeding querystring limits.
console.log('Clicking SendLocalEmail link:', uri);
link.href = uri;
document.body.appendChild(link); // Needed for Firefox
link.click();
document.body.removeChild(link);
}
};
function isEmpty(str) {
return (!str || str.length === 0);
}
Finally, be sure you include a reference to your .js file in the index.html file (also in the wwwroot folder):
<script src="GlobalFunctions.js"></script>
I place the above script reference below this line:
<script>navigator.serviceWorker.register('service-worker.js');</script>