How to insert a report into the body of a email
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:
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:
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:
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.
Ajouter un commentaire