How to validate External Mail Address in SAP ABAP using externel API

Hi Guys ,

               In this tutorial i am going to show you how to validate External mail address in SAP ABAP

Here am not going to check '@' or '.com' . I am using an external API to check whether  a mail id is

valid or not .

There are many ways that we could check a mail id . I will be using  an email validator api  .

And now i am going to show you how easily we could use this on SAP ABAP .

  • Checkout this code below

PARAMETERS: p_mail(100) LOWER CASE.                 " E-Mail id to be verified
DATA: http_client TYPE REF TO if_http_client .
DATA: w_string TYPE string ,
      w_result TYPE string ,
      f_str    type string ,
      r_str    TYPE string .
DATA: result_tab TYPE TABLE OF string.
  CLEAR w_string .

*concatnate the api with the email id below *
'**your acces key goes here**' p_mail '&VerificationLevel=3'
  w_string .

* This method is used to access an externel url and get response into an internel table *

  CALL METHOD cl_http_client=>create_by_url
      url                = w_string                                                "pushing url into the method
      client             = http_client
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.
  CALL METHOD http_client->send
      http_communication_failure = 1
      http_invalid_state         = 2.
  CALL METHOD http_client->receive
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3.
  CLEAR w_result .
  w_result = http_client->response->get_cdata( ).
  REFRESH result_tab .
  SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .      "result tab will have the response values

  READ TABLE result_tab INTO r_str INDEX 1.                                   "convert values into a string

  split r_str at '"' into table data(itab).                                   "split the response using '"' and put into another internel table

  read table itab into f_str index 12.                                        " value in the index 12 will show wheather the email is valid or not

  IF f_str = '1'.
    WRITE:/ 'Vaild Email Address'.
    clear f_str.
    read table itab into f_str index 16.                                      "value in the index 16 will show  the reason why the email is not valid
    WRITE:/ f_str.


  • First we try to put a wrong email id and see what happens 

  • The result is ...
  • Try with an actual just go with amazon customer care id 

  • Here it goes ...

  • I used a trial email validator api from .

    In order to get a  trial key just need to goto and put it your name and email id  or just play around with the code you could use any api using this code 

    If you enjoyed this post, Please Share!!


    Post a Comment

    Powered by Blogger.