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

Email is truncated when sent programatically from SAP to External system

Former Member
0 Likes
2,355

I am sending email through ABAP program to all employees of company.

(Note : sending docement format is 'HTML')

When I check in SAPConnect(scot), message is complete, but when I check it at receiver end , it is got truncated.

Pls help.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,471

Problem was to calculate doc size at each time and pass it with doc. object.

Thanks all for help.

6 REPLIES 6
Read only

brad_bohn
Active Contributor
0 Likes
1,471

What exactly was truncated? Have you checked multiple email clients, including web clients? Have you checked for OSS notes? Have you debugged the dispatch process for exceptions? Does it happen when you send to only one recipient? Be more specific...

Read only

Former Member
0 Likes
1,471

When I send as 'RAW' it not truncated, but when I send as 'HTM' , it is truncated after starting some rows for each mail.

Read only

0 Likes
1,471

Try thi

Call the FM to Send mail



       lv_subject type so_obj_des,
        lv_notif_typ type zde_hr_mail_typ ,
        lit_contents type bcsy_text,
        lwa_contents type line of bcsy_text,


    concatenate 'Social Status changed for:' lv_ename into lv_subject.

    clear lwa_contents.
    lwa_contents-line = '</br>Thanks &amp; Regards,</br>Employee Relations</br>Human Resources Department'.
    append lwa_contents to lit_contents.


    call function 'Z_SEND_MAIL' destination 'NONE'
      exporting
        p_lv_subject   = lv_subject
        p_lv_notif_typ = lv_notif_typ
        p_lv_content   = lit_contents.

FM:z_send_mail



function z_send_mail.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(P_LV_SUBJECT) TYPE  SO_OBJ_DES
*"     VALUE(P_LV_NOTIF_TYP) TYPE  ZDE_HR_MAIL_TYP
*"     VALUE(P_LV_CONTENT) TYPE  BCSY_TEXT
*"----------------------------------------------------------------------

  types: begin of t_rlist,
         usrname type syuname,
         rectype type zde_recptype,
         email type ad_smtpadr,
   end of t_rlist.

  data: it_rlist type table of t_rlist,
        wa_rlist like line of it_rlist,
        err_table	type table of	rpbenerr.

  data: l_ref_bcs type ref to cl_bcs,
        l_ref_document type ref to cl_document_bcs,
        l_o_sender type ref to cl_cam_address_bcs,
        l_ref_recipient type ref to if_recipient_bcs,
        l_ref_bcs_exception type ref to cx_bcs,
        lv_sent_to_all type os_boolean,
        lv_text type so_obj_des,
        status_mail type bcs_stml,
        requested_status type  bcs_rqst value 'E'.

  data: l_it_contents type bcsy_text,
        l_wa_contents type line of bcsy_text,
        lv_copy type c,
        lv_bcc type c.

**********************************************************************
* Get Email List
**********************************************************************
  select usrname rectype email
    into corresponding fields of table it_rlist
    from zhr_mailreceipt
    where wf_type = p_lv_notif_typ
    and isactive ='1'.

  loop at it_rlist into wa_rlist where usrname ne space.

    call function 'HR_FBN_GET_USER_EMAIL_ADDRESS'
      exporting
        user_id             = wa_rlist-usrname
        reaction            = 'X'
     importing
       email_address       = wa_rlist-email
*             SUBRC               =
          tables
            error_table         = err_table
              .
    modify it_rlist from wa_rlist transporting email where usrname = wa_rlist-usrname.

  endloop.
  delete it_rlist where email = space.
  sort it_rlist by rectype.

  try.
      l_ref_bcs = cl_bcs=>create_persistent( ).

      l_it_contents[] = p_lv_content[].

      clear l_wa_contents.
      l_wa_contents-line = '<BR/><BR/><BR/><BR/><p align="center"> <img src="kaleel.in/images/logo.png" alt="Unable to Display Logo"></p>'.
      append l_wa_contents to l_it_contents.

      clear l_wa_contents.
      l_wa_contents-line = '<BR/><BR/><BR/><BR/> <span style="font-variant: small-caps;">Note:This is SAP Generated Mail,Do not Reply</span>'.
      append l_wa_contents to l_it_contents.

      l_ref_document = cl_document_bcs=>create_document(
      i_type = 'HTM'
      i_text = l_it_contents
      i_subject = p_lv_subject ).

      l_ref_bcs->set_document( l_ref_document ).

      l_o_sender = cl_cam_address_bcs=>create_internet_address( i_address_string = 'sap_AT_kaleel.in' i_address_name = 'SAP Section' ).
      l_ref_bcs->set_sender( i_sender = l_o_sender ).

      lv_bcc = space.

      loop at it_rlist into wa_rlist where email ne space and rectype ne space.
        if wa_rlist-rectype = '01'.
          lv_copy = ''.
        elseif wa_rlist-rectype = '02'.
          lv_copy = 'X'.
        elseif wa_rlist-rectype = '03'.
          lv_bcc = 'X'.
        endif.

        l_ref_recipient = cl_cam_address_bcs=>create_internet_address( wa_rlist-email ).
        l_ref_bcs->add_recipient( i_recipient = l_ref_recipient
        i_copy = lv_copy " CC indicator
        i_blind_copy = lv_bcc
        ).
      endloop.

      status_mail = requested_status.
      call method l_ref_bcs->set_status_attributes
        exporting
          i_requested_status = requested_status
          i_status_mail      = status_mail.

      l_ref_bcs->set_send_immediately( 'X' ).

* send mail
      call method l_ref_bcs->send(
      exporting i_with_error_screen = 'X'
      receiving
      result = lv_sent_to_all ).

      if lv_sent_to_all = 'X' .
      endif.
      commit work.
    catch cx_bcs into l_ref_bcs_exception.
      if l_ref_bcs_exception is not initial.
        clear l_ref_bcs_exception.
      endif.
  endtry.

endfunction.

Mark as answered if its useful

Read only

Former Member
0 Likes
1,471

HI

Please go through below given link for sending mail to the external system.

http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage

Regards,

Ravi Grover

Read only

0 Likes
1,471

Please go through below given link for sending mail to the external system.

What specifically in Sandra's wiki addresses the issue the poster is asking about?

Read only

Former Member
0 Likes
1,472

Problem was to calculate doc size at each time and pass it with doc. object.

Thanks all for help.