Sending an Email from Radzen

Is there any Information/Documentation on sending an Email from Radzen. Example = Send Email Button on an Order Page, that Emails the order to the Supplier/Vendor, and cc Email to the User.


You can check this blog post:

I'm not getting this tutorial to work. Seems to me there are some errors in the tutorial, or I'm not understanding the flow in the route specifically: mail in ( /api/mail/sendmail), and MailController, Where the Controller name is SendEmailController. In any event I'm not getting this to work with a 404 error not found.

Thanks, mailMessage, {

public class MailController : Controller

[object Object]: {error: null, headers: Object, message: "Http failure response for http://localhost:5000/api/mail/sendmail: 404 Not Found", name: "HttpErrorResponse", ok: false...}

error: null

headers: Object

message: "Http failure response for http://localhost:5000/api/mail/sendmail: 404 Not Found"

name: "HttpErrorResponse"

ok: false

status: 404

statusText: "Not Found"

url: "http://localhost:5000/api/mail/sendmail"

There is a easier way to use this code now since you can call custom methods.

  1. Copy this code in your application server\ServerMethodsController.cs:
        public async System.Threading.Tasks.Task<IActionResult> SendMail(string to, string cc, string subject, string text)
            var client = new System.Net.Mail.SmtpClient("", 111);
            client.UseDefaultCredentials = false;
            client.EnableSsl = true;

            client.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword");

            var mailMessage = new System.Net.Mail.MailMessage();
            mailMessage.From = new System.Net.Mail.MailAddress("");


            if (!string.IsNullOrEmpty(cc))

            mailMessage.Body = text;

            mailMessage.Subject = subject;

            mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;

            await client.SendMailAsync(mailMessage);

            return Ok();

  1. Execute it suing "Invoke Custom Method" action:

I've changed the original method signature from the blog post to be easier to provide separate parameters.


Hi Enchev, here is what i have so far. The ServerMethodsController seems like it should be a no Brainer, The buttons click has two functions, 1) to sent the Email, and 2) to update the PurchaseOrderStatusId to "3" (Sent)


The last screen shows an exception "No such host is known". This means that your SmtpClient configuration isn't correct - the host name resolution failed. You are missing an "f" in

Thanks, Wasted most of the day that spelling error.

HI , states about System.Net.Mail:

It is usable in .NET Core, but its use isn't recommended.
Use MailKit or other libraries instead.

What does Radzen advice on this topic ?


1 Like

can't access the return OK(); function
Kindly tell what should be the Return function...

The return Ok() statement is only needed for action methods. In Razor functions you don't need it - just delete that line.

Deleted that line but still Displaying an error

The method should not return IActionResult it should be void. The original thread was open for Angular applications whereas you are using Blazor.

I've set the type to Void but Still error

@Owais_Raza is this code generated by Radzen? You cannot assign a variable to a void method ...

it is generated by Radzen

@Owais_Raza Are you using Invoke Method action? You need Execute C# in this case.

Yes, I was invoking custom method action...
Can you tell me what specific code is required to send an email???
I'm a lil bit confused...

@Owais_Raza the code is already included in the thread. You can also search online for instructions - this is generic .NET Core implementation and isn't related to Radzen.