# EasyBarCodeReadMail

| Support            | ![](assets/images/sample_programs/applies_to/cpp.svg) ![](assets/images/sample_programs/applies_to/cs.svg)   |
|--------------------|--------------------------------------------------------------------------------------------------------------|
| Required licenses  | **EasyBarCode**                                                                                              |
| Recommended images | Any image from the folder `Sample Images/EasyBarCode/MailBarCode`                                            |
| Location           | `Text and Code Reading/EasyBarCodeReadMail`                                                                  |

## Purpose

This sample program demonstrates how to:

- Read a mail bar code in an image.

![](assets/images/sample_programs/text_and_code-easybarcodereadmail.webp)

## Code highlights

1. Read the mail bar codes present in the image.
   ```c++
   m_Barcodes = m_Reader.Read(m_Source);
   ```
2. Retrieve the text encoded in the i^(th) bar code.
   ```c++
   string text = m_Barcodes[i].Text;
   ```
3. Retrieve the j^(th) component (for example the Postal Code or Address in the screenshot) encoded in the i^(th) bar code.
   ```c++
   string composed = m_Barcodes[i].ComponentStrings[j].Key + " : " + m_Barcodes[i].ComponentStrings[j].Value;
   ```
4. Draw the position of the i^(th) bar code on the image.
   ```c++
   m_Barcodes[i].Draw(e.Graphics);
   ```
