How to programmatically set the default email client settings for sending emails from FastReport.NET

2021-02-12

Like many other report generators, FastReport .NET allows you to send a report via email in any of the available export formats. You can send an e-mail either in the report preview mode or in the custom application code.

To send an email you need to set the sender, recipient settings.

On the Account tab, you set the email client settings for sending emails and the sender's address and name.

FastReport.NET

On the Email tab you set up the recipient's address, email subject, email text, and most importantly the report format to be attached to the email. When the email is sent, the report will be automatically exported in the specified format and attached to the email. 

FastReport.NET

Any settings you set will be saved as the default settings when you send the email, and you can use them in the future. The same is true when you initialize the email settings values in the application code in the EnvironmentSettings component. The settings will only be saved once the email has been sent. But what if you want the default email settings to be applied immediately, without having to send an email to save them? This might be useful if you are using the report generator in a multi-user application and want to make mail presets so that users only have to enter the recipient address and click the send button.

The default email settings are located in the FastReport .NET report generator configuration file, which is usually located at the specified path 

C:\Users\User\AppData\Local\FastReport\FastReport.config.

Open this file in a text editor and you will see an XML. Find the AccountSettings section and, if you have already sent mail from preview mode, you will see the default settings for sending mail. To edit this file in your custom application use the following code:

XmlItem xi = Config.Root.FindItem("EmailExport").FindItem("AccountSettings");
// save account info
xi.SetProp("Address", "a@a.com");
xi.SetProp("Name", "Name");
xi.SetProp("Template", "template");
xi.SetProp("Host", "host");
xi.SetProp("Port", "25");
xi.SetProp("UserName", "UserName");
xi.SetProp("Password", "Password");
xi.SetProp("EnableSSL", "1"); // "0" if SSL needs to be disabled

In this code, we read the configuration file and found the section for the mailing settings. And then - we set the settings. If this section or its properties are not in the configuration, they will be added automatically.

This way we can create pre-configured mail settings for our users.

.NET .NET FastReport FastReport Email Email
July 10, 2025

How to Build and Connect the Firebird Plugin in FastReport .NET

In this article, we will go through the process of building and connecting the Firebird plugin in FastReport .NET through the report designer and via code.
July 04, 2025

How to Transition from FastReport Publisher to the Corporate Server

In this material, we will discuss the reasons for replacing Publisher with the Corporate Server along with a migration plan.
June 27, 2025

Publisher — the Ideal Solution for Small and Medium-Sized Businesses

In this article, we will take a detailed look at how these services help address different user needs so that you can choose the solution that best fits your requirements.
Fast Reports
  • 800-985-8986 (English, US)
  • +31 97 01025-8466 (English, EU)
  • +49 30 56837-3928 (German, DE)
  • +55 19 98147-8148 (Portuguese, BR)
  • info@fast-report.com
  • 66 Canal Center Plaza, Ste 505, Alexandria, VA 22314

© 1998-2025 Fast Reports Inc.