Application Development and Automation 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: 
Read only

Error while sending Mail

Former Member
0 Likes
2,833

Hi,

I am getting an error while sending mail using CL_BCS.

I searched for the error but could not find the solution.

PFB the error

Regards,

Arvind.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,305

Hi Arvind,

Also check  in transaction SCOT if the e-mail is sent or not (node: INT -> SMTP ). Sometimes the default domain within SCOT is missing. also check in the ICM monitor (SMICM, menu GoTo -> Services ) whether the HTTP service is up and running.

you can also refere the program ( BCS_EXAMPLE_1) .

Thanks,

Deb

9 REPLIES 9
Read only

Former Member
Read only

Former Member
0 Likes
2,305

Hi Arvind,

At the execution of which method are you getting this error? does this mail have attachements? if possible post that part of the code .

Regards,

Akhila

Read only

0 Likes
2,305

Hi,

PFB the code

   */.. Add the spread sheet as attachment to document object
      lo_document->add_attachment(
      i_attachment_type    = gc_xls  

      i_attachment_subject = gv_title

      i_attachment_size    = gv_size
      i_att_content_hex    = gi_binary_content ).

Regards,

Arvind.

Read only

0 Likes
2,305

Pls check below sample code

FUNCTION ZNPI_SEND_MAIL.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(SUBJECT) TYPE  SO_OBJ_DES

*"     VALUE(MESSAGE_BODY) TYPE  BCSY_TEXT

*"     VALUE(ATTACHMENTS) TYPE  RMPS_T_POST_CONTENT OPTIONAL

*"     VALUE(SENDER_UID) TYPE  SYUNAME OPTIONAL

*"     VALUE(RECIPIENT_UID) TYPE  SYUNAME OPTIONAL

*"     VALUE(SENDER_MAIL) TYPE  ADR6-SMTP_ADDR OPTIONAL

*"     VALUE(RECIPIENT_MAIL) TYPE  ADR6-SMTP_ADDR OPTIONAL

*"  EXPORTING

*"     VALUE(RESULT) TYPE  BOOLEAN

*"  TABLES

*"      RECIPIENTS STRUCTURE  UIYS_IUSR OPTIONAL

*"----------------------------------------------------------------------

*Data Declaration

  DATA: lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,

          l_send type ADR6-SMTP_ADDR ,

          l_rec type  ADR6-SMTP_ADDR .

   Data : ITAB TYPE TABLE OF SVAL,

          LS_ITAB TYPE SVAL,

          i_RETURN.

     DATA:

     lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.

*     DATA:

*    lt_message_body TYPE bcsy_text VALUE IS INITIAL,

     DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL,

     attachment_subject type SO_OBJ_DES.

   DATA: lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.

   data: ls_recipient like line of recipients,

   ls_attachment like line of attachments.

  DATA: lv_recipient_uid TYPE uname,

  lv_recipient_mail TYPE adr6-smtp_addr.

*Prepare Mail Object

     CLASS cl_bcs DEFINITION LOAD.

     lo_send_request = cl_bcs=>create_persistent( ).

* Message body and subject

data: lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.

     lo_document = cl_document_bcs=>create_document(

     i_type = 'RAW'

     i_text =  message_body

     i_subject = subject ).

*Send  attachment

loop at attachments into ls_attachment.

     attachment_subject = ls_attachment-subject.

     TRY.

         lo_document->add_attachment(

         EXPORTING

         i_attachment_type = ls_attachment-OBJTP

         i_attachment_subject = attachment_subject

         i_att_content_hex = ls_attachment-CONT_HEX ).

       CATCH cx_document_bcs INTO lx_document_bcs.

     ENDTRY.

endloop.

* Pass the document to send request

     lo_send_request->set_document( lo_document ).

try.

     if sender_mail is not initial.

       lo_sender = cl_cam_address_bcs=>create_internet_address( sender_mail ).

           elseif sender_uid is not initial.

       lo_sender = cl_sapuser_bcs=>create( sender_uid ).

     else.

       lo_sender = cl_sapuser_bcs=>create( sy-uname ).

     endif.

* Set sender

     lo_send_request->set_sender(

     EXPORTING

     i_sender = lo_sender ).

        catch CX_ADDRESS_BCS.

          return.

        endtry.

* Set  recipients

if recipients[] is initial.

     if recipient_mail is not initial.

       lo_recipient = cl_cam_address_bcs=>create_internet_address( recipient_mail ).

           elseif recipient_uid is not initial.

       lo_recipient = cl_sapuser_bcs=>create( recipient_uid ).

     else.

       lo_recipient = cl_sapuser_bcs=>create( sy-uname ).

     endif.

     lo_send_request->add_recipient(

     EXPORTING

     i_recipient = lo_recipient

     i_express = 'X' ).

else.

loop at recipients into ls_recipient.

     if ls_recipient-iusrid is not initial.

       lv_recipient_uid = ls_recipient-iusrid.

       lo_recipient = cl_sapuser_bcs=>create( lv_recipient_uid ).

     elseif ls_recipient-email is not initial.

       lv_recipient_mail = ls_recipient-email .

       lo_recipient = cl_cam_address_bcs=>create_internet_address( lv_recipient_mail ).

     endif.

lo_send_request->add_recipient(

     EXPORTING

     i_recipient = lo_recipient

     i_express = 'X' ).

endloop.

endif.

try.

** Send email

     lo_send_request->send(

     EXPORTING

     i_with_error_screen = 'X'

     RECEIVING

     result = result ).

     COMMIT WORK.

     wait up to 1 seconds.

catch cx_send_req_bcs.

      result = ''.

endtry.

ENDFUNCTION.

Read only

0 Likes
2,305

Hi

I have written a similar code.

But still the problem exists.

Regards,

Arvind.

Read only

0 Likes
2,305

Hi,

Please check the attachment type. It should be among the listed entries in TSOTD table. Try using 'XXL' format.

Regards,

Akhila

Read only

Former Member
0 Likes
2,306

Hi Arvind,

Also check  in transaction SCOT if the e-mail is sent or not (node: INT -> SMTP ). Sometimes the default domain within SCOT is missing. also check in the ICM monitor (SMICM, menu GoTo -> Services ) whether the HTTP service is up and running.

you can also refere the program ( BCS_EXAMPLE_1) .

Thanks,

Deb

Read only

0 Likes
2,305

Hi,

I have verified through ZOSG tcode.

Mail is not being sent.

HTTP service is running.

Regards,

Arvind.

Read only

0 Likes
2,305

Hi Arvind,

You can ask with your basis team if any chnages were made by them.

The error would be in create_attachment method only.

Check method "HTTP_POST_DOCUMENT" used in above method.

Hope this helps.

Regards,

gaurav.