Skip to Content
author's profile photo Former Member
Former Member

how to sending simple text in the mail body

Hi friends,

How to send simple text in the mail body through ABAP code

plz send me the related code and setting for that mail.

Thanks&Regards,

Srinivas

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 10:55 AM

    Hi,

    Use the below code

    ****************************************

    • Check the mail in T-code SBWP

    • To check the send mail status T-Code SOST

    ***********************************************

    TABLES:pa0001.

    DATA: v_ans,

    v_body_lines TYPE i.

    • Local declarations

    CONSTANTS:

    c_note_00 TYPE solisti1 VALUE 'NOTE',

    c_note_01 TYPE solisti1 VALUE

    'Do not reply to this email, instead please contact the compensation ',

    c_note_02 TYPE solisti1 VALUE

    'specialist (see above for contact details). This will help avoid ',

    c_note_03 TYPE solisti1 VALUE

    'unnecessarily delaying your request.'.

    DATA: it_packing_list TYPE TABLE OF sopcklsti1,

    wa_packing_list LIKE LINE OF it_packing_list,

    it_receivers TYPE TABLE OF somlreci1,

    wa_receivers LIKE LINE OF it_receivers,

    it_mailbody TYPE TABLE OF solisti1,

    wa_mailbody LIKE LINE OF it_mailbody.

    DATA: it_doc TYPE sodocchgi1.

    DATA: v_sent_all TYPE boolean.

    START-OF-SELECTION.

    • mail header

    it_doc-obj_descr = 'Hello'.

    • Add the recipients email address

    CLEAR wa_receivers.

    REFRESH it_receivers.

    wa_receivers-receiver = 'XXXXX@XXXX.COM'.

    wa_receivers-rec_type = 'U'.

    wa_receivers-com_type = 'INT'.

    wa_receivers-notif_del = 'X'.

    wa_receivers-notif_ndel = 'X'.

    APPEND wa_receivers TO it_receivers.

    wa_receivers-receiver = 'XXXXX@XXXX.COM'.

    wa_receivers-rec_type = 'U'.

    wa_receivers-com_type = 'INT'.

    wa_receivers-notif_del = 'X'.

    wa_receivers-notif_ndel = 'X'.

    APPEND wa_receivers TO it_receivers.

    • Mail Body

    CLEAR wa_mailbody.

    REFRESH it_mailbody.

    wa_mailbody-line = 'Hi All,'.

    APPEND wa_mailbody TO it_mailbody.

    wa_mailbody-line = ' '.

    APPEND wa_mailbody TO it_mailbody.

    wa_mailbody-line = 'This is a test mail'.

    APPEND wa_mailbody TO it_mailbody.

    wa_mailbody-line = ' '.

    APPEND wa_mailbody TO it_mailbody.

    DO 3 TIMES.

    wa_mailbody-line = ' '.

    APPEND wa_mailbody TO it_mailbody.

    ENDDO.

    wa_mailbody-line = c_note_00.

    APPEND wa_mailbody TO it_mailbody.

    wa_mailbody-line = c_note_01.

    APPEND wa_mailbody TO it_mailbody.

    wa_mailbody-line = c_note_02.

    APPEND wa_mailbody TO it_mailbody.

    wa_mailbody-line = c_note_03.

    APPEND wa_mailbody TO it_mailbody.

    • Describe the body of the message

    CLEAR wa_packing_list.

    REFRESH it_packing_list.

    wa_packing_list-transf_bin = space.

    wa_packing_list-head_start = 1.

    wa_packing_list-head_num = 0.

    wa_packing_list-body_start = 1.

    DESCRIBE TABLE it_mailbody LINES v_body_lines.

    wa_packing_list-body_num = v_body_lines.

    wa_packing_list-doc_type = 'RAW'.

    APPEND wa_packing_list TO it_packing_list.

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

    document_data = it_doc

    put_in_outbox = 'X'

    commit_work = 'X'

    IMPORTING

    sent_to_all = v_sent_all

    TABLES

    packing_list = it_packing_list

    contents_txt = it_mailbody

    receivers = it_receivers

    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.

    ELSE.

    WRITE:/ 'Mail has been sent to the receivers sucessfully'.

    ENDIF.

    Regards,

    siva chalasani.

    <b>Reward points if usefull</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 10:59 AM

    try this...

    FORM send_file_as_email_attachment .

    DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.

    DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.

    DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.

    DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.

    DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.

    DATA : i_body TYPE soli_tab WITH HEADER LINE.

    • DATA: it_attach LIKE it_display1 OCCURS 0 WITH HEADER LINE.

    DATA: doc_chng LIKE sodocchgi1.

    DATA: tab_lines LIKE sy-tabix.

    DATA: att_lines TYPE i.

    • DATA: lv_lines TYPE i.

    DATA: file TYPE string.

    data: g_datum like sy-datum.

    data: g_datum1(10) type c.

    DATA: len TYPE n.

    LOOP AT it_email.

    CLEAR : objpack,

    objhead,

    objbin,

    objtxt,

    reclist.

    REFRESH: objpack,

    objhead,

    objbin,

    objtxt,

    reclist.

    g_datum = sy-datum - 1.

    concatenate g_datum6(2) '.' g_datum4(2) '.' g_datum+0(4) into

    g_datum1.

    • doc_chng-obj_descr = 'Aged Stock more than 45 Days'.

    CONCATENATE 'Aged Stock more than 45 Days' '-' it_email-vkbur INTO

    doc_chng-obj_descr.

    CONCATENATE 'Please find enclosed Aged Stock Details ( >45days ) report as on'

    g_datum1

    INTO objtxt-line SEPARATED BY space.

    APPEND objtxt.

    objtxt-line = ' '.

    APPEND objtxt.

    objtxt-line = 'Regards'.

    APPEND objtxt.

    objtxt-line = 'LIS SAP Projects'.

    APPEND objtxt.

    objtxt-line =

    'PS: Pls send feedback for futher improvements to SAP office.'.

    APPEND objtxt.

    DESCRIBE TABLE objtxt LINES tab_lines.

    READ TABLE objtxt INDEX tab_lines.

    doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

    • CLEAR objpack-transf_bin.

    objpack-head_start = 1.

    objpack-head_num = 1.

    objpack-body_start = 1.

    objpack-body_num = tab_lines.

    objpack-doc_type = 'TXT'.

    • objpack-obj_name = 'Run_prog'.

    • objpack-obj_descr = 'Agestock.txt'.

    • lv_lines = tab_lines.

    APPEND objpack.

    *CONCATENATE 'Plant' 'Material Number' 'Qty(More than 45days)'

    *'Amount' INTO

    • it_display SEPARATED BY space.

    • append objbin.

    • clear: objbin.

    CLEAR:it_display2.

    REFRESH it_display2.

    it_display2-werks = 'Plant|'.

    it_display2-matnr = 'Material Number'.

    it_display2-qty = '|Qty > 45 days'.

    it_display2-amount = ' |Amount'.

    APPEND it_display2.

    it_display2-werks = ''.

    it_display2-matnr = ''.

    it_display2-qty = ''.

    it_display2-amount = ''.

    APPEND it_display2.

    CLEAR : it_display2.

    sort it_display1 by amount descending.

    LOOP AT it_display1 WHERE werks = it_email-vkbur.

    • AT FIRST.

    *CONCATENATE 'Plant ' 'Material Number' 'Qty(More than 45days)'

    *'Amount' INTO

    • objbin-line SEPARATED BY space.

    • append objbin.

    • clear: objbin.

    • ENDAT.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

    EXPORTING

    input = it_display1-matnr

    IMPORTING

    output = it_display1-matnr.

    it_display1-qty = TRUNC( it_display1-qty ).

    MOVE-CORRESPONDING it_display1 TO it_display2.

    APPEND it_display2.

    CLEAR:it_display1,it_display2,objbin.

    CLEAR:it_display1.

    ENDLOOP.

    objbin[] = it_display2[].

    DESCRIBE TABLE objbin LINES tab_lines.

    objhead = 'Suug'.

    APPEND objhead.

    *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    objpack-transf_bin = 'X'.

    objpack-head_start = 3.

    objpack-head_num = 1.

    objpack-body_start = 1.

    objpack-body_num = tab_lines.

    objpack-doc_type = 'RAW'.

    objpack-obj_name = 'Run_prog'.

    objpack-obj_descr = 'Agestock.txt'.

    APPEND objpack.

    *&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

    reclist-receiver = 'xxx@mailbox.com'.

    reclist-rec_type = 'U'.

    APPEND reclist.

    =====================================================================

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

    document_data = doc_chng

    commit_work = 'X'

    TABLES

    packing_list = objpack

    object_header = objhead

    contents_bin = objbin

    contents_txt = objtxt

    receivers = reclist

    EXCEPTIONS

    too_many_receivers = 1

    document_not_sent = 2

    operation_no_authorization = 4

    OTHERS = 99.

    CLEAR : it_email.

    ENDLOOP.

    ENDFORM. "send_mail

    Message was edited by:

    Sugumar Ganesan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 11:00 AM

    Hi Srinivas,

    Check the following programs and u can find it very easy to send:

    1) BCS_EXAMPLE_1

    2)BCS_EXAMPLE_2

    3)BCS_EXAMPLE_3

    4)BCS_EXAMPLE_4

    5)BCS_EXAMPLE_5

    6)BCS_EXAMPLE_6

    regards,

    madhu

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 11:03 AM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.