Skip to Content
author's profile photo Former Member
Former Member

EMail Address validation before sending

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Nov 12, 2015 at 03:03 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 12, 2015 at 03:13 AM
    Add a comment
    10|10000 characters needed characters exceeded

    • 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.

  • Posted on Nov 12, 2015 at 05:54 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.