New to Telerik Reporting? Start a free 30-day trial
Implementing Send Mail Message
Updated on Aug 28, 2026
This tutorial elaborates on how to implement the SendMailMessage method required for sending email messages through report viewers that are connected to a Reporting REST Service.
Controllers Setup
When the Reporting REST Service has been implemented using controllers, override the SendMailMessage method of the ReportsController.
C#
protected override HttpStatusCode SendMailMessage(MailMessage mailMessage)
{
using (var smtpClient = new SmtpClient("smtp.companyname.com", 25))
{
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
smtpClient.Send(mailMessage);
}
return HttpStatusCode.OK;
}Minimal API Setup
When the Reporting REST Service has been implemented using Minimal API, first implement a method that sends the MailMessage object via the SmtpClient:
C#
public static HttpStatusCode MyMailSender(MailMessage message)
{
try
{
using (var smtpClient = new SmtpClient("tests.com", 26))
{
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Credentials = new NetworkCredential("user", "pass");
smtpClient.EnableSsl = true;
smtpClient.Send(message);
}
return HttpStatusCode.OK;
}
catch
{
return HttpStatusCode.InternalServerError;
}
}
Then, this method can be passed alongside the ReportServiceConfiguration of the Reporting REST Service when adding it in the starting point of the application, for example, the Program.cs file:
C#
var mailContext = new MailContext(MyMailSender);
var reportServiceConfiguration = new ReportServiceConfiguration
{
ReportingEngineConfiguration = builder.Configuration,
HostAppId = "Reporting",
Storage = new FileStorage(),
ReportSourceResolver = new TypeReportSourceResolver()
.AddFallbackResolver(
new UriReportSourceResolver(reportsPath))
};
builder.Services.AddRazorPages().AddTelerikReporting(reportServiceConfiguration, mailContext);