2012 Jun 21 4:00 PM
Hi Guys,
I've created code that will send an e-mail to an external user who will reply to a different sender. I've tested this code in a 4.7 system and it works perfectly, but when I moved it to an ECC system I get this short dump: UNCAUGHT_EXCEPTION - CX_OS_OBJECT_NOT_FOUND.
I've added the code below. Does anyone have any suggestions?
PARAMETERS: P_MAIL TYPE AD_SMTPADR DEFAULT '[email protected]'.
LW_HTML-LINE = 'This is Line 1'.
APPEND LW_HTML TO IT_HTML.
CLEAR LW_HTML.
LW_HTML-LINE = 'This is Line 2'.
APPEND LW_HTML TO IT_HTML.
CLEAR LW_HTML.
**---create persistent send request
OBJ_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
*---Email Subject
LV_SUBJECT = 'TESTMAIL'. "text-016'.
*---Create Document
LV_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'HTM' "'RAW'
I_TEXT = IT_HTML
I_SUBJECT = LV_SUBJECT ).
**---Add document to send request
CALL METHOD obj_send_request->set_document( lv_document ).
*---Set sender
LV_SENDER_MAIL = '[email protected]'.
LV_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
LV_SENDER_MAIL ).
CALL METHOD OBJ_SEND_REQUEST->SET_SENDER
EXPORTING
I_SENDER = LV_SENDER.
*---Add recipient (e-mail address)
LV_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
P_MAIL ).
*---Add recipient with its respective attributes to send request
CALL METHOD OBJ_SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = LV_RECIPIENT
I_EXPRESS = 'X'.
CALL METHOD OBJ_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
COMMIT WORK.
*---Send document ---------------------------------------
TRY.
CALL METHOD OBJ_SEND_REQUEST->SEND(
EXPORTING
I_WITH_ERROR_SCREEN = 'X'
RECEIVING
RESULT = LV_SENT_TO_ALL ).
IF LV_SENT_TO_ALL = 'X'.
COMMIT WORK.
WRITE: / 'Email successfully sent'.
ELSE.
WRITE: / 'Error while sending an email'.
ENDIF.
CATCH CX_SEND_REQ_BCS.
WRITE: / 'Error while sending an email'.
ENDTRY.
2012 Jun 22 6:45 AM
Hi Edwin ,
I just yried out the code which you had posted.
I guess you can comment the COMMIT statement after
CALL METHOD obj_send_request->set_send_immediately( 'X' ).
and execute it.
I just tried it out in ECC system and it is executing, without generating any dump.
in foreground mode.
Message was edited by: mayur priyan
Hi Guys,
I've created code that will send an e-mail to an external user who will reply to a different sender. I've tested this code in a 4.7 system and it works perfectly, but when I moved it to an ECC system I get this short dump: UNCAUGHT_EXCEPTION - CX_OS_OBJECT_NOT_FOUND.
I've added the code below. Does anyone have any suggestions?
PARAMETERS: P_MAIL TYPE AD_SMTPADR DEFAULT '[email protected]'.
LW_HTML-LINE = 'This is Line 1'.
APPEND LW_HTML TO IT_HTML.
CLEAR LW_HTML.
LW_HTML-LINE = 'This is Line 2'.
APPEND LW_HTML TO IT_HTML.
CLEAR LW_HTML.
**---create persistent send request
OBJ_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
*---Email Subject
LV_SUBJECT = 'TESTMAIL'. "text-016'.
*---Create Document
LV_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'HTM' "'RAW'
I_TEXT = IT_HTML
I_SUBJECT = LV_SUBJECT ).
**---Add document to send request
CALL METHOD obj_send_request->set_document( lv_document ).
*---Set sender
LV_SENDER_MAIL = '[email protected]'.
LV_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
LV_SENDER_MAIL ).
CALL METHOD OBJ_SEND_REQUEST->SET_SENDER
EXPORTING
I_SENDER = LV_SENDER.
*---Add recipient (e-mail address)
LV_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
P_MAIL ).
*---Add recipient with its respective attributes to send request
CALL METHOD OBJ_SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = LV_RECIPIENT
I_EXPRESS = 'X'.
CALL METHOD OBJ_SEND_REQUEST->SET_SEND_IMMEDIATELY( 'X' ).
COMMIT WORK.
*---Send document ---------------------------------------
TRY.
CALL METHOD OBJ_SEND_REQUEST->SEND(
EXPORTING
I_WITH_ERROR_SCREEN = 'X'
RECEIVING
RESULT = LV_SENT_TO_ALL ).
IF LV_SENT_TO_ALL = 'X'.
COMMIT WORK.
WRITE: / 'Email successfully sent'.
ELSE.
WRITE: / 'Error while sending an email'.
ENDIF.
CATCH CX_SEND_REQ_BCS.
WRITE: / 'Error while sending an email'.
ENDTRY.
2012 Jun 21 6:54 PM
Hi Edwin,
Just debug and find which class is throwing this exception and if it is having all the data required.
For any help go through the below standard program, which would be helpful.
BCS_EXAMPLE_6.
Regards,
Sandeep
2012 Jun 21 8:55 PM
Hi Sandeep,
Sorry. But I forgot to mention in my first post that if I run this in debug mode it actually works, it only dumps in foreground mode.
Thanks.
2012 Jun 22 2:25 AM
Why don't you use Function Module SO_DOCUMENT_SEND_API1?
It is the best way and easiest way to send emails.
2012 Jun 22 6:45 AM
Hi Edwin ,
I just yried out the code which you had posted.
I guess you can comment the COMMIT statement after
CALL METHOD obj_send_request->set_send_immediately( 'X' ).
and execute it.
I just tried it out in ECC system and it is executing, without generating any dump.
in foreground mode.
Message was edited by: mayur priyan
2012 Jun 22 8:54 AM
Hi Mayur.
You are a rock star. It works perfectly if I only comment out the COMMIT WORK.
Thanks, much appreciated.