logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Customer panel Support
    • en
    • ru
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to insert a report into the body of a email
  • How to programmatically set the default email client settings for sending emails from FastReport.Net

    February 12, 2021

    Like many other report generators, FastReport.Net allows you to send a report via email in

    read more
  • How to use QR-codes in FastReport.Net

    February 15, 2017

    Nowadays “QR-codes” are gaining their popularity. Unlike conventional barcodes, “QR-codes” allow you to encode more

    read more
  • How to make wedding invitations from Excel

    August 25, 2017

    Do you have a celebration on the occasion of the wedding? Do you need to

    read more
  • How to connect to VistaDB

    November 15, 2019

    The Vista database will fall into the type of embedded databases. These databases differ from

    read more
  • How to disable printing reports and other items from the menu when viewing the report FastReport.Net

    February 29, 2020

    The main report viewing tool FastReport.Net is Viewer. This viewer has a rich toolkit for

    read more

How to insert a report into the body of a email

July 9, 2020

By default, FastReport.Net allows you to send e-mails with an attached report file in one of the available export formats. However, it is sometimes necessary to include the report content in the body of the email. This feature may be useful if you intend to discuss the report content in correspondence. Responses to an email with an attached report file will no longer have that file. Therefore, you will need to take the time to find an email with an attachment in order to view the report and understand what it is about. It can also be useful if you are viewing mail on a mobile device. Downloading a report file and opening it in another application is not very convenient.

In FastReport.Net we can send emails from the code of a user application, which means that we can set up the settings for emails. Unfortunately, an e-mail message can contain only plain text, without pictures and html markup. Therefore, we can use exporting the report to the txt format to insert it into the body of the message.

Of course, the txt export format imposes many limitations - complete absence of graphics, interactive objects and complex markup - only text. Therefore, it should be used only in simple reports with clear data hierarchy and simple markup. The ideal example - simple lists. Let's consider an example of sending a email with a report in the message:

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//Create export to txt format
FastReport.Export.Text.TextExport text = new FastReport.Export.Text.TextExport();
 
//Execute export to the file or stream
 report.Export(text, "Template.txt");
 
//Create export to email
 FastReport.Export.Email.EmailExport email = new FastReport.Export.Email.EmailExport();
 
//Set email subject
 email.Subject = "Test";
 
//Set message body – reply in text format
 email.MessageBody = File.ReadAllText("Template2.txt");
 
//Set recipient address
 email.Address = "gromozeka@gmail.com";
 
//Set sender address
 email.Account.Address = "gromozeka@yandex.ru";
 
//Set email host
 email.Account.Host = "smtp.yandex.ru";
 
//Set recipient name
 email.Account.Name = "gromozeka";
 
//Set username
 email.Account.UserName = "gromozeka";
 
//Set user password
 email.Account.Password = "******";
 
//Set email server port
 email.Account.Port = 25;
 
//Enable encryption if needed
 email.Account.EnableSSL = true;
 
//Send email
 email.SendEmail(report);

  The mechanism of sending emails to FR.Net implies sending an email with an attached report, so a report template will be attached by default if you have not specified a certain export format for the attached file.

Now let's see what we get in the e-mail. But first, take a look at the original report:

Report template for the email

 There's beautiful frames, gradient headlines and pictures. There's not gonna be any of that in the text view of the report.

This is what the email with the report in the message looks like:

How the report looks in email body

The report is quite recognizable. If it is not important for you to show the appearance of the report, but only to deliver the information, then this method of sending the report in the body of the message will be quite suitable.

about product download buy
avatar
Dmitriy Fedyashov
Head of QA
.NET FastReport Email

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Our team
  • Contact us

© 1998-2021 by Fast Reports Inc.

  • Privacy Policy