2015 Nov 12 2:56 AM
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.
2015 Nov 12 3: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.
2015 Nov 12 3: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.
2015 Nov 12 3:09 AM
Hi,
Thanks for the response.
Is there an FM that can check the MAIL SENT status ?
2015 Nov 12 3:10 AM
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
2015 Nov 12 3:13 AM
Hi,
I hope couples posts are available.
http://scn.sap.com/thread/3817584
http://wiki.scn.sap.com/wiki/display/Snippets/Validate+Email+using+Regular+Expression
2015 Nov 12 5:04 AM
2015 Nov 12 5:24 AM
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.
2015 Nov 12 5: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
2015 Nov 12 6:04 AM
But Ragavendiran, I think, ADR6 accepts any combination of <letters><@><.> !!
Cheers,
Kripa Rangachari.
2015 Nov 12 6:19 AM
Hi Kripa,
Validation done against E-mail addresses maintained(standard) table. I hope email id maintaining is done by basis when creating user id.