Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

EMail Address validation before sending

Former Member
0 Kudos
2,252

Hi Experts,

I have created a customized program to send emails.

Is there a way to validate the email address used ?

I have a requirement to save data into a ztable when email is successfuly sent.

With my code below, it is being saved even though the email is not correct.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

       EXPORTING

         document_data              = wa_doc_chng

         put_in_outbox              = 'X'

         commit_work                = 'X'

       TABLES

         packing_list               = i_objpack

         object_header              = wa_objhead

         contents_bin               = i_objbin

         contents_txt               = i_objtxt

         receivers                  = i_reclist

       EXCEPTIONS

         too_many_receivers         = 1

         document_not_sent          = 2

         document_type_not_exist    = 3

         operation_no_authorization = 4

         parameter_error            = 5

         x_error                    = 6

         enqueue_error              = 7

         OTHERS                     = 8.

     IF sy-subrc <> 0.

*      WRITE:/ 'Error When Sending the File', sy-subrc.

       MESSAGE 'Error When Sending the File' TYPE 'S'.

     ELSE.

       WAIT UP TO 1 SECONDS.

       SUBMIT rsconn01

         WITH mode = 'INT'

         WITH output = ' '

         AND RETURN.

*      WRITE:/ 'Mail sent'.

       MESSAGE 'Kindly check email for status' TYPE 'S'.

       it_counter-ebeln = wa_data-ebeln.

       it_counter-submi = wa_data-submi.

       it_counter-zdate = sy-datum.

       it_counter-ztime = sy-uzeit.

       it_counter-username = sy-uname.

       it_counter-type = 'EMAIL'.

       it_counter-emailadd = wa_data-SMTP_ADDR.

       MODIFY ZRFQ_PRINT_CTR FROM it_counter.

     ENDIF.

1 ACCEPTED SOLUTION

former_member182877
Participant
0 Kudos
906

Hi Jepoy,

You can carry out the basic validation checked like whether the String contains '@' symbol followed by a '.'. And the string should start with Alphabets / Numbers and not with '-; etc.,

I think only after the MAIL is sent .. you will be knowing whether it is a valid / not.

Or probably you can have the program extended to check the MAIL SENT status and then if it is successful, probably you can have the ID stored else leave it off!

Cheers,

Kripa Rangachari.

9 REPLIES 9

former_member182877
Participant
0 Kudos
907

Hi Jepoy,

You can carry out the basic validation checked like whether the String contains '@' symbol followed by a '.'. And the string should start with Alphabets / Numbers and not with '-; etc.,

I think only after the MAIL is sent .. you will be knowing whether it is a valid / not.

Or probably you can have the program extended to check the MAIL SENT status and then if it is successful, probably you can have the ID stored else leave it off!

Cheers,

Kripa Rangachari.

0 Kudos
906

Hi,

Thanks for the response.

Is there an FM that can check the MAIL SENT status ?

0 Kudos
906

Hi Jepoy

In additions to Kripa's recommendation's keep in mind that a Successful/Unsuccessful email send notification may not be known to the system immediately...or at all.

Regards

Arden

0 Kudos
906

So for this Jepoy which Version / EnhP of SAP you are in!?

0 Kudos
906

Hi Jepoy!,

I can think of 2 possibilties here.

May be your business requires the Ztable to be updated with right mail ids!! - Iam not sure...

1. There is a table SOES wherein the Status of mail sent are stored (You cannot have it done in your program since this table update might happen at any time based on the time of mail sent!!)

2. You can write a BATCH Job!... like every 2 hours / 4 hours... Identify your conent of mail, Read the status from SOES and then update the Z table via your batch job!..

Hope this helps.

Cheers,

Kripa Rangachari.

ragavendiran_s2
Explorer
0 Kudos
906

Hi Jepoy,

you can validate the email address by below mentioned code

  SELECT SINGLE usr21~bname INTO lv_name

             FROM usr21

               INNER JOIN adr6

                  ON  usr21~addrnumber = adr6~addrnumber

                 AND usr21~persnumber = adr6~persnumber

               WHERE adr6~smtp_addr = p_mail." Mail id

0 Kudos
906

But Ragavendiran, I think, ADR6 accepts any combination of <letters><@><.> !!

Cheers,

Kripa Rangachari.

0 Kudos
906

Hi Kripa,


Validation done against E-mail addresses maintained(standard)  table. I hope email id maintaining is done by basis when creating user id.