logo
small logo
  • Products
  • Buy
  • Support
  • Articles
  • Customer panel Support
    • en
    • ru
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to programmatically set the default email client settings for sending emails from FastReport.NET
  • How to use Online Designer in ASP .Net Core

    January 17, 2018

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

    read more
  • How to use WebReport with ASP .Net Web Core application

    January 17, 2018

    Recently FastReport introduced a new library under the .Net - FastReport Core platform. This is

    read more
  • FastCube - High-Speed OLAP Cube Engine and Pivot Grid

    February 29, 2020

    It is difficult to imagine data analysis without OLAP (On-Line Analytical Processing) technology. Although there

    read more
  • Report generators family FastReport brief review

    March 23, 2020

    Without reporting it is impossible to carry on business in any sphere of life. Bureaucracy

    read more
  • How to update the FastReport.Core web report

    September 21, 2020

    Sometimes you need to update the report, for example if you input a new variable

    read more

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

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