Application Development 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: 

HTML-Email only one row in Soli-table?

Former Member
0 Kudos
2,744

I have used the function efg_gen_send_email and changed it from the type "RAW" to "HTM", that it is possible to use HTML tags.

But when I fill the table of the format SOLI, my email shows only the content of the first row of this table!

The other rows, I have appended, are not being displayed in the email.

I can´t use only one row, because the type of soli is only 255 characters.

Any idea what I can do to send bigger emails or how the other lines can be displayed in the mail?

Tnak you very much!

Pablos

17 REPLIES 17

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
626

I'm wondering what your HTML code looks like. Can you post the part where you are building the HTML.

Regards,

Rich Heilman

Former Member
0 Kudos
626

Hi Rich,

I can show you my HTML code, but it´s not the problem....

When I´m using only words and no HTML-Tags, the email shows also only the first line of the table. It is not depending on what I´m typing..... tags or only text. :o(

0 Kudos
626

Ok, and you are saying that it is putting all lines in one in your email, or only writing the first line of your internal table to the email?

Can you post your ABAP code where you are building this table and maybe calling the function?

Regards,

Rich Heilman

Former Member
0 Kudos
626

Ok, I´m only testing the module at the moment. So I´m filling the table manually.

You can try it out yourself. The Module is

EFG_GEN_SEND_EMAIL

I have changed the TYPE inside the function to "HTM". And now it´s only showing the first row of the table for the email.

Thanks

Message was edited by: Arne Hein

Former Member
0 Kudos
626

Hi

This works for me :

REPORT ZKTEST1.

DATA: it_tab_soli TYPE soli_tab.

DATA: address TYPE string.

data : wa_soli like soli.

  • generating the e-mail

CALL FUNCTION 'EFG_GEN_GET_USER_EMAIL'

EXPORTING

i_uname = '501108832'

IMPORTING

e_email_address = address.

wa_soli-line = 'TESTLINE 1'.

append wa_soli to it_tab_soli.

wa_soli-line = 'TESTLINE 2'.

append wa_soli to it_tab_soli.

*building and sending the e-mail

CALL FUNCTION 'EFG_GEN_SEND_EMAIL'

EXPORTING

i_title = 'anytitle'

i_sender = 'emailid@xxx.com'

i_recipient = address

i_flg_commit = 'X'

i_flg_send_immediately = 'X'

TABLES

i_tab_lines = it_tab_soli.

I get 2 lines in the email .

Regards

Kalpana

0 Kudos
626

Kalpana,

it looks like the issue is with sending HTML email.. it works fine with type 'RAW'..

Suresh Datti

0 Kudos
626

I don't have that function module in my system. This sample program works great for us. We are on 46c.




report zrich_0002.

data: maildata   like sodocchgi1.
data: mailtxt    like solisti1 occurs 10 with header line.
data: mailrec    like somlrec90 occurs 0  with header line.

start-of-selection.

  clear:    maildata, mailtxt,  mailrec.
  refresh:  mailtxt, mailrec.

  perform build_text_message.
  perform build_receivers.
  perform send_mail_nodialog..

************************************************************************
*      Form  BUILD_TEXT_MESSAGE
************************************************************************
form build_text_message.


  maildata-obj_name = 'TEST'.
  maildata-obj_descr = 'Test Subject'.


  mailtxt  = '<html>'.
  append mailtxt.
  mailtxt  = '<head>'.
  append mailtxt.
  mailtxt  = '<title>Untitled Document</title>'.
  append mailtxt.
  mailtxt  = '<meta http-equiv="Content-Type" content="text/html;'.
  append mailtxt.
  mailtxt  = 'charset=iso-8859-1">'.
  append mailtxt.
  mailtxt  = '</head>'.
  append mailtxt.
  mailtxt  = '<body>'.
  append mailtxt.
  mailtxt  = '<div align="center"><em><font' .
  append mailtxt.
  mailtxt  = 'color="#0000FF" size="+7" face="Arial,'.
  append mailtxt.
  mailtxt  = 'Helvetica, sans-serif">THIS'.
  append mailtxt.
  mailtxt  = '  IS A TEST </font></em><font' .
  append mailtxt.
  mailtxt  = 'color="#0000FF" size="+7" face="Arial,'.
  append mailtxt.
  mailtxt  = 'Helvetica, sans-serif"></font>'.
  append mailtxt.
  mailtxt  = '</div>'.
  append mailtxt.
  mailtxt  = '</body>'.
  append mailtxt.
  mailtxt  = '</html>'.
  append mailtxt.

endform.

************************************************************************
*      Form  BUILD_RECEIVERS
************************************************************************
form build_receivers.

*  mailrec-receiver = you@yourcompany.com'.
  mailrec-rec_type  = 'U'.
  append mailrec.

endform.

************************************************************************
*      Form  SEND_MAIL_NODIALOG
************************************************************************
form send_mail_nodialog.

  call function 'SO_NEW_DOCUMENT_SEND_API1'
       exporting
            document_data              = maildata
            document_type              = 'HTM'
            put_in_outbox              = 'X'
       tables
            object_header              = mailtxt
            object_content             = mailtxt
            receivers                  = mailrec
       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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

endform.

Regards,

Rich HEilman

0 Kudos
626

Hi Arne,

1. How does the first line look like in the mail?

2. where are you changing the type to 'HTM' as 'RAW' is hardcoded in the function?

Suresh

Former Member
0 Kudos
626

Hi all!

Thank You for the answers!

Rich: I have testet the function module SO_new_......

but I don´t get any email! I have tried that one before and don´t know, why it´s not working. :o(

The only module that is working, is the EFG_GEN_SEND_EMAIL.

Suresh: I have copied the content of this module and changed the type in my code to 'HTM'. When You call that function, you only see the first line of the table, but html is working. Don´t know why I can´t see the other lines. :o(

This is my module now:


FUNCTION ZTAN2_SEND_EMAIL.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     REFERENCE(IM_UNAME) TYPE  ZT2_UNAME
*"     REFERENCE(I_TITLE) TYPE  STRING
*"     REFERENCE(I_SENDER) TYPE  STRING
*"     REFERENCE(I_RECIPIENT) TYPE  STRING
*"     REFERENCE(I_FLG_COMMIT) TYPE  C DEFAULT 'X'
*"     REFERENCE(I_FLG_SEND_IMMEDIATELY) TYPE  C DEFAULT 'X'
*"  TABLES
*"      I_TAB_LINES
*"  EXCEPTIONS
*"      NOT_QUALIFIED
*"      FAILED
*"----------------------------------------------------------------------

  CONSTANTS: con_fname TYPE funcname VALUE 'EFG_GEN_SEND_EMAIL'.

  DATA: l_rcl_send_req   TYPE REF TO cl_bcs.
  DATA: l_text           TYPE bcsy_text.
  DATA: l_rcl_doc        TYPE REF TO cl_document_bcs.
  DATA: l_rcl_sender     TYPE REF TO cl_cam_address_bcs.
  DATA: l_rcl_recipient  TYPE REF TO if_recipient_bcs.
  DATA: l_rcx_bcs        TYPE REF TO cx_bcs.
  DATA: l_rcx_addr       TYPE REF TO cx_address_bcs.

  DATA: l_smtp_addr      TYPE adr6-smtp_addr.
  DATA: l_subject        TYPE so_obj_des.
  DATA: l_tab_soli       TYPE soli_tab.
  DATA: l_soli           TYPE soli.
  DATA: wa_user          TYPE zt2_user.
  DATA: l_vorname        TYPE zt2_uname.
  DATA: l_nachname       TYPE zt2_uname.

  TRY.

      l_rcl_send_req = cl_bcs=>create_persistent( ).

**absender
      TRY.
          l_smtp_addr = i_sender.

          CALL METHOD cl_cam_address_bcs=>create_internet_address
            EXPORTING
              i_address_string = l_smtp_addr
              i_address_name   = l_smtp_addr
            RECEIVING
              result           = l_rcl_sender.

        CATCH cx_address_bcs INTO l_rcx_addr.

      ENDTRY.

      CALL METHOD l_rcl_send_req->set_sender
        EXPORTING
          i_sender = l_rcl_sender.


*      recipient (e-mail address) -----------------------
*     create recipient - please replace e-mail address !!!
      l_smtp_addr = i_recipient.
      l_rcl_recipient = cl_cam_address_bcs=>create_internet_address(
                                        l_smtp_addr ).

*     add recipient with its respective attributes to send request
      CALL METHOD l_rcl_send_req->add_recipient
        EXPORTING
          i_recipient = l_rcl_recipient.

** document
      APPEND LINES OF i_tab_lines TO l_tab_soli.
      l_subject  = i_title.

*  HTML-Typ festlegen
      l_rcl_doc = cl_document_bcs=>create_document(
                      <b>i_type    = 'HTM'</b>
*                      i_type    = 'OTF'
                      i_text    = l_tab_soli
                      i_length  = '100'
                      i_subject = l_subject ).

*     add document to send request
      CALL METHOD l_rcl_send_req->set_document( l_rcl_doc ).

      if not i_flg_send_immediately is initial.
        l_rcl_send_req->set_send_immediately( 'X' ).
      endif.

      l_rcl_send_req->set_status_attributes( 'N' ).

      l_rcl_send_req->send( ).


      IF NOT i_flg_commit IS INITIAL.
        TRY.
            COMMIT WORK.
          CATCH cx_root.

        ENDTRY.
      ENDIF.

    CATCH cx_bcs INTO l_rcx_bcs.

    CATCH cx_root.

  ENDTRY.


ENDFUNCTION.

Message was edited by: Arne Hein

Former Member
0 Kudos
626

Hey Rich,

I have now tried the module SO_NEW_DOCUMENT_SEND_API1 again and I have seen, that my mails only get the state "waiting". If I´m starting the report to send the waiting messages, it´s working. What do I have to do, to send the mails automatically?

I have tried out your example, but when I look at the email, the content is empty! I have tried it in Lotus notes and in Gmail, but in both there is no content.

When I´m viewing the email in transaction SOST, I can see the html text.

what do I do wrong?

Cheers Arne

0 Kudos
626

Hi Arne,

Try passing EXPRESS = 'X' in Receivers parameter.

Regards,

Ravi

0 Kudos
626

Hey Ravi,

for what function do you mean? I´ll try it for the "SO_NEW_DOCUMTENT_SEND_API1" now.

Do you have an idea, why I don´t see any content, when I´m using the type HTM?

Cheers Arne

0 Kudos
626

Hi Arne,

I've checked the possible values that can be passed to the Document type. There is no document type for html as such. You can check the table for TSOTD for the possible document types.Probably, this might be the problem.

Ravi

0 Kudos
626

Hi Satish,

I don´t get any email, when I´m starting your program. I also don´t see any entries in transaction SOST.

I don´t understand, why I don´t see any content in my emails! Only if when I´m choosing the Type "RAW". Don´t know what to do...

0 Kudos
626

Arne:

Did you solve the problem?

i Have the same problem, the content is empty!!

Regards,Cristian

0 Kudos
626

after the FM try using

SUBMIT rsconn01 WITH mode = 'INT'

WITH output = 'X'

AND RETURN.

Former Member
0 Kudos
626

Hi Please try the following. It should help u.

report zemail no standard page heading line-size 220.

data: message_content like soli occurs 10 with header line,

receiver_list like soos1 occurs 5 with header line,

w_object_hd_change like sood1.

start-of-selection.

  • Receivers

receiver_list-recextnam = 'dude@domain.com'.

receiver_list-recesc = 'E'.

receiver_list-sndart = 'INT'

receiver_list-sndpri = '1'.

append receiver_list.

  • General data

w_object_hd_change-objla = sy-langu.

w_object_hd_change-objnam = 'Object name'.

w_object_hd_change-objsns = 'P'.

w_object_hd_change-file_ext = 'HTM'. "<--this is important

  • Mail subject

w_object_hd_change-objdes = 'HTML from SAP/ABAP'.

  • Mail body

append 'Message content' to message_content.

append '<b>How''s this for sending HTML E-mail from SAP?</b>' to

message_content.

append '<p>New paragraph</p>' to message_content.

append '<p>Apostrophe&#8217s</p>' to message_content.

  • Call function to send email - SAPConnect needs to be configured

call function 'SO_OBJECT_SEND'

exporting

object_hd_change = w_object_hd_change

object_type = 'RAW'

owner = sy-uname

tables

objcont = message_content

receivers = receiver_list.

Satish