New to Telerik Reporting? Download free 30-day trial

Implement Send Mail Message

This tutorial elaborates how to implement the SendMailMessage method of the ReportsController. This is required to enable the send document endpoint used for HTML5 Report Viewer Send Mail Message functionality.

To send e-mail use the MailMessage with SMTP client as shown in the following code snippet:

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;
}

{{source=CodeSnippets\MvcVB\Controllers\ReportsController.vb region=SendMailMessage_Implementation}}

Protected Overrides Function SendMailMessage(ByVal mailMessage As MailMessage) As HttpStatusCode
    Using smtpClient = New SmtpClient("smtp.companyname.com", 25)
        smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
        smtpClient.EnableSsl = True
        smtpClient.Send(mailMessage)
    End Using

    Return HttpStatusCode.OK
End Function

See Also

In this article