How to verify email in 1C?

Tatiana Prozorova

18.06.2020 7 min

The process of verifying an email address is called Email Verification. Verification improves the odds that email belongs to a real person. The primary purpose of email verification is to guarantee that a real person will receive all your sent emails.

How can we verify email in 1C? We can do it with different email verification web services. For example, let’s use https://debounce.io/ service. The opportunity to try for free how it will work the main advantage of this service. The first 100 calls are free.

The first step is to register the debounce.io. You can do it the same way as always.


debounce.io


The next step is to receive your debounce.io API key.

Once you have received the API key, you can open 1C and start writing code.

Let’s add the constant, where we will store the API key:

API key


Add the Common form on which this constant will be located:


API key form 

Please, add one Enumeration with four values: SaveToSend, Invalid, Risky, Unknown – they are will be as verification answers from the debounce.io

Enumeration


 Then we add one Catalog “Clients” with two attributes “Email” (string) and “EmailVerifying” (Enums.EmailVerifying), the Item form for it.

 Catalog “Clients”

 

We rename the “Description” field to “Full Name”- to be clear for understanding that we will store here. Also, the “Email verifying” field we make as Unenabled, we don’t need the opportunity the users to change this field. Here is we will store the debounce.io answer for our request.  

 Catalog Form Wizard

 

Catalog “Clients” Form


We add the new command VerifyEmail, “Create on a client” action and via drag-and-drop, we make a “Verify email” button.


“Verify email” button

Well - now let’s move on to the 1C source code.

At first, we create VerifyEmail() procedure. Here is we make a request to debounce.io, receive the verifying answer, and put it into the “Email verifying” field.

&AtClient

Procedure VerifyEmail(Command)

            // Insert handler content.

            Token = getApiKey();

            If Not ValueIsFilled(Token) Then

                        Message("Please, fill the Constant: Debounce Api Key");

                        Return;

            EndIf;

           

            sEmail = Object.Email;

            if (sEmail <> "") then

                        Host     = "api.debounce.io";

                        HTTPRequest = New HTTPRequest;

                        HTTPRequest.ResourceAddress = "v1/?api=" + Token + "&email=" + sEmail+"&photo=true";

                        HTTPConnection         = New HTTPConnection(host,,,,,10,New OpenSSLSecureConnection);

                        HTTPAnswer               = HTTPConnection.Get(HTTPRequest);

                        stringAnswer= HTTPAnswer.GetBodyAsString();

                        JSONReader = New JSONReader;

                        JSONReader.SetString(stringAnswer);

                        JsonResult = ReadJson(JSONReader,True);      

                       

                        For each strResult in JsonResult Do

                                   If (strResult.Key = "debounce") Then

                                               For each strDebounce in  strResult.Value Do

                                                           If (strDebounce.Key = "result") Then

                                                                                   Object.EmailVerifying = SetupEmailVerifying(strDebounce.Value);                                                     

                                                           EndIf;

                                               EndDo;

                                   EndIf;

                        EndDo;

            Else

                        Message("Please, fill the Email field");

            EndIf;

EndProcedure

 

&AtServer

Function SetupEmailVerifying(EmailVerifyingValue)

           

            If (EmailVerifyingValue = "Safe to Send") Then

                        Object.EmailVerifying = Enums.EmailVerifying.SafeToSend;

            ElsIf (EmailVerifyingValue = "Invalid") Then

                        Object.EmailVerifying = Enums.EmailVerifying.Invalid;

            ElsIf (EmailVerifyingValue = "Risky") Then

                        Object.EmailVerifying = Enums.EmailVerifying.Risky;

            ElsIf (EmailVerifyingValue = "Unknown") Then

                        Object.EmailVerifying = Enums.EmailVerifying.Unknown;

            EndIf;

           

EndFunction

 

GetApiKey() procedure returns us the debounce.io API key from the Constants.

 

&AtServer

Function GetApiKey()

            Return Constants.DebounceAPIKey.Get();

EndFunction

 

EmailOnChange() procedure sets up the “Email verifying” field = “Not Verified” as default after email changing.

 

EmailOnChange() procedure

 

&AtClient

Procedure EmailOnChange(Item)

            Object.EmailVerifying = "Not Verified";

EndProcedure

 

That is all, let’s save and update our configuration and see how the Email Verification will work at our 1C system.

Run the 1C in 1C:Enterprise mode, open Tools->Debounce API Key, and put in the “Debounce API Key” field the API key we received at the beginning.

 

Tools->Debounce API Key

Create a new Client item and fill all information. After Email filling, you will see “Not Verified” as email verifying information.


new Client item


Push the “Verify Email” button. You will receive “Invalid” if an email doesn’t exist.

Push “Verify Email” button


And “Save to Send” if the email exists


Save to Send 

You can download this Example for your own application.

If you have any questions about this article, you can always get answers on our forum: https://1c-dn.com/forum/

Stay with us!

Be the first to know tips & tricks 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.