logo
small logo
  • Produits
  • Acheter
  • Assistance
  • About
  • Panneau du client Assistance
    • en
    • de
    • JP
    • ZH
  • Page d'accueil
  • /
  • Articles
  • /
  • How to insert a report into the body of a email
  • Toilet paper printing

    30 mars 2020

    Gentlemen jokes aside! Today we are talking about toilet paper. This essential hygiene product was

    read more
  • How to use Online Designer in ASP .NET Core

    17 janvier 2018

    One of the novelties by FastReport .NET 2018 was the adaptation of OnlineDesigner to the

    read more
  • PreviewControl.OnPrint and PreviewControl.OnExport Events

    1 octobre 2020

    In FastReport 2019.4 added the ability to subscribe to PreviewControl.OnPrint and PreviewControl.OnExport events, which are

    read more
  • FastReport .NET packages and .NET 5.0

    17 décembre 2020

    UPD: Applies to the versions of FastReport .NET before 2022.2. License packages are now available

    read more
  • Working with NuGet packages in FastReport

    22 novembre 2021

    UPD: Applies to the versions of FastReport .NET before 2022.2. License packages are now available

    read more

How to insert a report into the body of a email

9 juillet 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.

A propos de notre produit Acheter
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport Email

Ajouter un commentaire
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
  • Acheter
  • Télécharger
  • Documentation
  • Avis
  • Comment désinstaller nos produits
  • FAQ
  • Tutoriel vidéo
  • Forum
  • Articles
  • Nos actualités
  • Dossier Presse
  • Partenaires
  • Extended licensing
  • Nous contacter

© 1998-2023 by Fast Reports Inc.

  • Politique de confidentialité
  • Pas une offre publique