Sending report in PDF to Email from application code

2016-04-05

It is no secret that FastReport .Net allows you to send reports by email. But few people know how to do it by using the code in a custom application. In such way that you wouldn't have to run a report and send it via email manually. The required reports will be automatically sent to a specified e-mail address with help one button, or schedule.

Let's consider the example of sending the report in PDF format by e-mail.

Create WindowsForms application. Add buttons and two text fields. In the first one, we will input recipient's email address, and the second - mail server for outgoing mail.

We will need the following libraries:

1
2
3
using FastReport;
using FastReport.Export;
using FastReport.Utils;

Create an event handler for the button click:     

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 private void button1_Click(object sender, EventArgs e)
 {
 Config.ReportSettings.ShowProgress = false; //Disable progress window
 Report report1 = new Report(); //Create new report object
 report1.Load(Environment.CurrentDirectory+"\\text.frx"); //Load report
 report1.Prepare(); //Prepare report
 FastReport.Export.Pdf.PDFExport pdf = new FastReport.Export.Pdf.PDFExport(); //Cteate PDF export
 FastReport.Export.Email.EmailExport email = new FastReport.Export.Email.EmailExport(); //Create Email export
 
 //email mailer settings
 email.Account.Address = "gromozekaster@yandex.ru";
 email.Account.Name = "TestUser";
 email.Account.Host = textBox2.Text;
 email.Account.Port = 25;
 email.Account.UserName = "Gromozekaster";
 email.Account.Password = "Password";
 email.Account.MessageTemplate = "Test";
 email.Account.EnableSSL = true;
 
 //email addressee settings
 email.Address = textBox1.Text;
 email.Subject = "Test Report";
 email.MessageBody = "Test message";
 
 email.Export = pdf; //Set export type
 email.SendEmail(report1); //Send email
 }

First of all I disabled the progress window in the report settings, but you can skip this step. If you do not need it, just do not write this line of code. Then create an instance of a report object and load the report into it. Before the export you need to prepare a report (Prepare), in other words - build it. Since the title of the article contains “PDF”, let's create an object of export to PDF.  Likewise we create export to email.

Now we can customize the export settings in the Email. In the Account - the sender's settings. Basically it is the outgoing mail server settings.

Next - set the parameters of the recipient as well as the email address, subject line, message text and export to the desired file type. Here it should be noted that is not necessary to export to PDF, you need only to create an export object. Email export makes exports to the specified format.

If you do not specify Export parameter, then the report will be sent in the FPX format. This file is preview of the report. You can view, print or export the report, but can not edit it.

Finally, we will send a letter using Sendmail method. Be sure to pass the report object to this method.

Considered method will be useful for standard emails, for example, you can arrange to automatically broadcast daily reports to your chief email.

.NET FastReport PDF Report Email .NET FastReport PDF Report Email
08 de setembro de 2026

Respostas às perguntas frequentes sobre o formato FP3

Vamos detalhar 11 perguntas comuns sobre o formato FP3: o que são esses arquivos, como eles diferem dos arquivos FR3, quais programas podem abri-los e como convertê-los em PDF.
04 de setembro de 2026

Como exportar um relatório do FastReport .NET para o formato DXF

Neste artigo, veremos os métodos de exportação de um relatório para o formato DXF e também analisaremos como fica o resultado obtido após a abertura do arquivo em um aplicativo CAD.
03 de agosto de 2026

Como exportar um relatório do FastReport .NET para PostScript

Neste artigo, veremos, por meio de um exemplo prático, como exportar um relatório do FastReport .NET para o formato PostScript, abordando a configuração dos parâmetros e a implementação programática.

© 1998-2026 Fast Reports Inc.