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

Sending Body of letter Through mail along with PDF file.

Dear friends,

I want to write some text in the mail(Body) while sending the PDF file.

Now I am sending PDF file , besides PDF file I have to write some text in the mail.

Please help me .

Thanks ,

Praveen.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Apr 24, 2007 at 12:46 PM

    HI,

    You have to fill <b>contents_txt</b> of function module to display body of the letter.

    check this sample code

      APPEND 'Hi,' TO CONTENTS_TXT.
      CONCATENATE 'Attached you will find the Report' '-' 'ZTESTPROG'
      '-' TRDIRT-TEXT INTO V_TEXT.
      APPEND V_TEXT TO CONTENTS_TXT.
    
      PACKLIST_COUNTER = 1.
    **-Populate body of message into contents_txt
      PERFORM CREATE_PACKLIST_ENTRY USING CONTENTS_TXT
                                          'RAW'
                                 CHANGING PACKLIST_WA
                                          PACKLIST_COUNTER.
      APPEND PACKLIST_WA TO PACKING_LIST.
    
    *&-----------------------------------------------------------------
    *&      Form  create_packlist_entry
    *&-----------------------------------------------------------------
    *       text
    *------------------------------------------------------------------
    
    FORM CREATE_PACKLIST_ENTRY  
                 USING  CONTENTS TYPE STANDARD TABLE        
                        FORMAT TYPE SO_OBJ_TP
                  CHANGING  PACKLIST_WA TYPE SOPCKLSTI1
                        PACKLIST_COUNTER TYPE I.
    
      DATA LV_LINES TYPE I.
      CLEAR PACKLIST_WA.
    
    * get the table length of the attachment
      DESCRIBE TABLE CONTENTS LINES LV_LINES.
    
    * set binary flag for binary content to mark that this packlist ent
    * is meant for table contents_hex and not for contents_bin
      IF FORMAT = 'ALI'.
        PACKLIST_WA-TRANSF_BIN = 'X'.
      ENDIF.
    
    **--Attchment's description and format
      CONDENSE P_ATTACH NO-GAPS.
    
      IF P_HTML EQ GC_X.
        CONCATENATE P_ATTACH 'htm' INTO PACKLIST_WA-OBJ_DESCR
                                   SEPARATED BY '.'.
      ENDIF.
    
    * attchment's description and format
      PACKLIST_WA-DOC_TYPE   = FORMAT.
    
    * describe start and length in contents_txt or contents_hex
    * which table is meant is decided by the transf_bin flag set above
      PACKLIST_WA-BODY_START = PACKLIST_COUNTER.
      PACKLIST_WA-BODY_NUM   = LV_LINES.
    
    * increase counter to have the starting line for the next attachmen
      PACKLIST_COUNTER = PACKLIST_COUNTER + LV_LINES.
    
    ENDFORM. 

    Regards,

    Sailaja.

    Message was edited by:

    Sailaja N.L.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 24, 2007 at 12:52 PM

    here is sample code.... Check the perform set_up_email_body.....

    FORM send_mail .

    • Set up the header,body ,file attachment of the message.

    PERFORM set_up_email_hdr.

    PERFORM set_up_email_body.

    PERFORM set_up_att_file.

    CLEAR: wa_objtxt.

    SORT t_fieldcat BY no_out col_pos.

    • Set up patcking list for attachment

    wa_objpack-body_start = w_tabln + 1.

    • Loop at report and separate by semi-colons

    CLEAR: w_tabln.

    SORT t_fieldcat BY no_out col_pos.

    • Loop at report and append header values

    LOOP AT t_fieldcat INTO fs_fieldcat WHERE no_out = space.

    IF wa_objtxt IS INITIAL.

    wa_objtxt = fs_fieldcat-seltext_l.

    ELSE.

    CONCATENATE wa_objtxt

    fs_fieldcat-seltext_l

    INTO wa_objtxt

    SEPARATED BY c_comma.

    ENDIF. " IF WA_OBJTXT ...

    CONDENSE wa_objtxt NO-GAPS.

    ENDLOOP. " LOOP AT T_FIELDCAT ...

    IF sy-subrc EQ 0.

    APPEND wa_objtxt TO t_objtxt.

    ENDIF. " IF SY-SUBRC ...

    • Fill Email attachment

    PERFORM fill_email_report.

    DESCRIBE TABLE t_objtxt LINES w_tabln.

    CLEAR W_LINE.

    READ TABLE t_objtxt INTO w_line INDEX w_tabln.

    IF SY-SUBRC EQ 0.

    fs_docda-doc_size = ( w_tabln - c_1 ) * 255 + STRLEN( w_line ).

    wa_objpack-body_num = w_tabln.

    wa_objpack-doc_size = w_tabln * 255.

    APPEND wa_objpack TO t_objpack.

    • Add receipients to the mail.

    PERFORM add_recipients.

    • send the mail

    PERFORM call_send.

    ENDIF. " IF SY-SUBRC EQ 0.

    ENDFORM. " SEND_MAIL

    &----


    *& Form add_recipients

    &----


    • This subroutine is used to add receipients to send mail.

    ----


    • There are no parameters passed to this subroutine.

    ----


    FORM add_recipients .

    IF p_user IS NOT INITIAL.

    wa_receiver-receiver = p_user.

    wa_receiver-rec_type = c_u.

    APPEND wa_receiver TO t_receiver.

    ELSE.

    wa_receiver-receiver = p_dlist.

    wa_receiver-rec_type = c_c.

    APPEND wa_receiver TO t_receiver.

    ENDIF. " IF P_USER ...

    ENDFORM. " ADD_RECIPIENTS

    &----


    *& Form call_send

    &----


    • This subroutine is used to send the mail.

    ----


    • There are no parameters passed to this subroutine.

    ----


    FORM call_send .

    IF t_objtxt[] IS NOT INITIAL.

    • Send the mail.

    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

    EXPORTING

    document_data = fs_docda

    put_in_outbox = c_x

    commit_work = c_x

    TABLES

    packing_list = t_objpack

    object_header = t_objhead

    contents_txt = t_objtxt

    receivers = t_receiver

    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 NE 0.

    MESSAGE s100(ra) WITH text-e05.

    STOP.

    ELSE.

    MESSAGE s100(ra) WITH text-026.

    ENDIF. " IF SY-SUBRC ...

    ELSE.

    MESSAGE s100(ra) WITH text-029.

    STOP.

    ENDIF. " IF T_OBJTXT[] ...

    ENDFORM. " CALL_SEND

    &----


    *& Form set_up_email_hdr

    &----


    • This subroutine is used to Setup the attributes of the Document

    ----


    • There are no interface parameters to this subroutine.

    ----


    FORM set_up_email_hdr .

    MOVE text-i03 TO fs_docda-obj_name.

    IF sy-sysid+0(1) NE c_p.

    CONCATENATE text-i02 text-i03 INTO fs_docda-obj_descr.

    ELSE.

    MOVE text-i03 TO fs_docda-obj_descr.

    ENDIF. " IF SY-SYSID+0(1) ...

    ENDFORM. " SET_UP_EMAIL_HDR

    &----


    *& Form set_up_email_body

    &----


    • This subroutine is used to set body of an email

    ----


    • There are no interface parameters to this subroutine.

    ----


    FORM set_up_email_body .

    • Setting the attributes of the document.

    IF P_ZCR3 EQ C_X.

    wa_objtxt-line = text-007.

    ELSEIF P_REL EQ C_X AND P_CHECK NE C_X.

    wa_objtxt-line = text-008.

    ELSEIF P_REL EQ C_X AND P_CHECK EQ C_X.

    wa_objtxt-line = text-008.

    ELSE.

    wa_objtxt-line = text-009.

    ENDIF. " IF P_ZCR3 ...

    APPEND wa_objtxt TO t_objtxt.

    DESCRIBE TABLE t_objtxt LINES w_tabln.

    CLEAR W_LINE.

    READ TABLE t_objtxt INTO w_line INDEX w_tabln.

    IF SY-SUBRC EQ 0.

    fs_docda-doc_size = ( w_tabln - 1 ) * 255 + STRLEN( w_line ).

    wa_objpack-head_start = c_1.

    wa_objpack-head_num = c_0.

    wa_objpack-body_start = c_1.

    wa_objpack-body_num = w_tabln.

    wa_objpack-doc_type = c_RAW.

    APPEND wa_objpack TO t_objpack.

    ENDIF. " IF SY-SUBRC EQ 0.

    ENDFORM. " SET_UP_EMAIL_BODY

    &----


    *& Form set_up_att_file

    &----


    • This subroutine is used to set up an attachment file.

    ----


    • There are no interface parameterst that need to be passed to

    • this subroutine.

    ----


    FORM set_up_att_file .

    • Attaching the file to the mail.

    wa_objhead-line = c_fname.

    APPEND wa_objhead TO t_objhead.

    wa_objpack-head_start = c_1.

    wa_objpack-head_num = c_1.

    wa_objpack-body_start = w_tabln.

    wa_objpack-doc_type = c_CSV.

    IF P_ZCR3 EQ C_X.

    wa_objpack-obj_name = text-012.

    wa_objpack-obj_descr = text-012.

    ELSEIF P_REL EQ C_X.

    wa_objpack-obj_name = text-027.

    wa_objpack-obj_descr = text-027.

    ELSE.

    wa_objpack-obj_name = text-028.

    wa_objpack-obj_descr = text-028.

    ENDIF. " IF P_ZCRE EQ....

    ENDFORM. " SET_UP_ATT_FILE

    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.