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.

Thanks

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

this.http.post(http://localhost:5000/api/mail/sendmail, mailMessage, {
headers

[Route("api/[controller]/[action]")]
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:
        [HttpPost]
        public async System.Threading.Tasks.Task<IActionResult> SendMail(string to, string cc, string subject, string text)
        {
            var client = new System.Net.Mail.SmtpClient("smtp.example.com", 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("youremail@example.com");

            mailMessage.To.Add(to);

            if (!string.IsNullOrEmpty(cc))
            {
                mailMessage.CC.Add(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.

1 Like

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)

thanks

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 office365.com.

Thanks, Wasted most of the day that spelling error.