Sending reports by email from the 1C platform

Alexander Biryukov

11.03.2020 7 min

Earlier, we created two reports (InventoryList and ProductList) on the 1C platform. In this example, we used the built-in mechanism, the Data composition system for developing reports without writing a single line of code in our solution.

In practice, our system often requires functions when it is necessary to send the generated reports to our contractors or employees by email. Let’s now realize this feature, and this time we need to write some code.

Open the external report InventoryList.erf in the Designer. Add a form for this report (pictures 1 and 2):



Now open this form and add the new attribute ToMail to it. This attribute will contain the email address of the recipient. The type of the new attribute is String.

Immediately place a new attribute on the form (picture 3):


Then create a new form command Send. Similarly, put it on the form (picture 4) and write the program code for this command (Listing 1):


Listing 1.


Procedure Send(Command)

      stringTempFileName = GetTempFileName("xls");


      EmailProfile = New InternetMailProfile;

      EmailProfile.SMTPServerAddress     = "your SMTP server"; //

      EmailProfile.SMTPUser              = "your email login"; //

      EmailProfile.SMTPPassword          = "your password";

      EmailProfile.SMTPUseSSL            = True;

      EmailProfile.SMTPPort              = 465;

      EmailProfile.SMTPAuthentication = SMTPAuthenticationMode.Login;

      EMail = New InternetMailMessage;

      Text                    = EMail.Texts.Add("Hello World!");

      Text.TextType           = InternetMailTextType.PlainText;

      EMail.Subject           = "Subject this message";

      EMail.From              = "your email address";

      EMail.SenderName = "From J.B.";



      Mail = New InternetMail;



            Message("Connection established.");


            Message("Connection not established. Error: " + ErrorDescription());





            Message("Message sent.");


            Message("Message not sent. Error: " + ErrorDescription());





Briefly understand how the program code works.

First, we save the report results to a file in Excel format:

      stringTempFileName = GetTempFileName("xls");


Next, the objects “InternetMailProfile”, “InternetMailMessage” and “InternetMail” are created sequentially, and the properties of these objects are filled...

Don’t forget to add the report recipient:


and add the previously generated Excel file with our report:


After that, an attempt is made to connect to the mail server:


If the connection is successful, then an attempt is made to send an email:


Finally, close the connection to the mail server:


And that is all! See how easy it is!

Let’s now check how our code works. Let’s launch the 1C platform in the dialogue mode, open the external report InventoryList.erf, generate a report - for this, click the Run report button.

Now, in the field To mail, please enter the email address of the recipient of our report and click the Send button. If you have correctly specified the parameters of the SMTP server, the email with the report is sent at this moment (picture 5):


This is what the mail already came to the addressee looks like (picture 6):


As you can see - using the 1C platform, it’s effortless to send any data by email.

You can download these reports for your own application.

Please, supplement your suggestions for the development of demo applications in our forum.

Stay with us - it will be more interesting further!

Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.