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

sending a pdf attachment thru mail..

hi experts.

I am sending spool request to e-mail, that is done thru Sap connect. A background process, whose driver program is RSCONN01 with variant SAPCONNECTINT, is called and then the mail is sent to the e-mail address with that document as pdf attachment. I want to change the subject of the mail as well as the name of attachment. Your help will be really appreciated, i have been trying to solve this since a week now.

there is a device configured as mail-printer which does the conversion frm otf to PDF. And we do not use CL_BCS.

thanks in advance,

Gaurav

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Oct 17, 2006 at 08:03 AM

    hi,

    see this sample code.

    *-MAIN PROCESSING SECTION

    clear: ltb_objbin, ltb_objtxt, ltb_objpack, lwa_doc_chng.

    refresh: ltb_objbin, ltb_objtxt, ltb_objpack.

    • Control Data

    lwa_doc_chng-obj_name = 'URGENT'.

    lwa_doc_chng-sensitivty = 'P'.

    lwa_doc_chng-no_change = 'X'.

    lwa_doc_chng-priority = '1'.

    lwa_doc_chng-obj_prio = '1'.

    lwa_doc_chng-obj_langu = sy-langu.

    lwa_doc_chng-no_change = 'X'.

    • Email Subject

    lwa_doc_chng-obj_descr = pw_subject.

    • Email Body

    ltb_objtxt[] = ptb_body[].

    CLEAR ltb_objtxt.

    DESCRIBE TABLE ltb_objtxt LINES lw_tab_lines.

    IF lw_tab_lines GT 0.

    READ TABLE ltb_objtxt INDEX lw_tab_lines.

    lwa_doc_chng-doc_size =

    ( lw_tab_lines - 1 ) * 255 + STRLEN( ltb_objtxt ).

    CLEAR ltb_objpack-transf_bin.

    ltb_objpack-body_start = 1.

    ltb_objpack-body_num = lw_tab_lines.

    ltb_objpack-doc_type = 'RAW'.

    APPEND ltb_objpack.

    ENDIF.

    • Attachment

    • Move the binary attachment to other internal table.

    ltb_objbin[] = ptb_pdf255[].

    ltb_objpack-transf_bin = 'X'.

    ltb_objpack-body_start = 1.

    • Get the number of lines in the Attachment (PDF FILE)

    DESCRIBE TABLE ltb_objbin LINES lw_tab_lines.

    ltb_objpack-body_num = lw_tab_lines.

    ltb_objpack-doc_type = 'PDF'.

    ltb_objpack-obj_descr = pw_filename.

    ltb_objpack-obj_name = pw_filename.

    ltb_objpack-doc_size = lw_tab_lines * 255.

    APPEND ltb_objpack.

    • Call the function to send the PDF file by email

    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

    EXPORTING

    document_data = lwa_doc_chng

    put_in_outbox = 'X'

    TABLES

    packing_list = ltb_objpack

    contents_bin = ltb_objbin

    contents_txt = ltb_objtxt

    receivers = ptb_recipients

    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.

    CASE sy-subrc.

    WHEN 0.

    WHEN 1. RAISE too_many_receivers.

    WHEN 2. RAISE document_not_sent .

    WHEN 3. RAISE document_type_not_exist.

    WHEN 4. RAISE operation_no_authorization.

    WHEN 5. RAISE parameter_error.

    WHEN 7. RAISE enqueue_error .

    WHEN OTHERS. RAISE x_error.

    ENDCASE.

    rgds

    anver

    if hlpd pls mark points

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 08:34 AM

    Hi,

    Subject of email can be changed using parameter specified

    in parameter DOCUMENT_DATA of function

    DOCUMENT_DATA :

    OBJ_NAME - Name of document.

    OBJ_DESCR - Title (short description) of document.

    Thanks.

    Mark points if helpful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 08:06 AM

    check this code it may help u.

    FORM send_mail USING p_y16m_rcp_par STRUCTURE y16m_rcp_par.

    • Have a subject for the mail

    g_s_document_data-obj_name = text-t02.

    g_s_document_data-obj_descr = text-t03.

    • Fill receiver information

    g_s_receivers-rec_type = p_y16m_rcp_par-rec_type.

    g_s_receivers-rec_id = p_y16m_rcp_par-rec_id.

    g_s_receivers-express = 'X'.

    APPEND g_s_receivers TO g_t_receivers.

    • Call function to send mail

    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

    EXPORTING

    document_data = g_s_document_data

    document_type = 'RAW'

    • PUT_IN_OUTBOX = ' '

    • IMPORTING

    • SENT_TO_ALL =

    • NEW_OBJECT_ID =

    TABLES

    • OBJECT_HEADER =

    object_content = g_t_object_content

    • CONTENTS_HEX =

    • OBJECT_PARA =

    • OBJECT_PARB =

    receivers = g_t_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.

    ENDIF.

    ENDFORM. " SEND_MAIL

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 17, 2006 at 08:14 AM

    hi anversha,

    thanks for ur help.this system is already implemented. they have got their method of sending document thru mail. they have got method of converting to PDF. I want a solution that falls within their given standards.

    thanks for ur help..

    gaurav

    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.