Smartform as Email Body

Hi,
  I have a requirement to send the smartform as mail body. I was able to send the smartform as PDF attachment but we need it mail body. I tried converting to html but the data, tables and images are displaying in the distored way. Will it be possible to convert the smartform data to image and send as mail body? Please respond.
Thanks!

Hi,
     Try by below way
1) Generate a spool of that smartform.
2) Get the spool number from TSP01 table.
3) Get the html content of the spool, it can be done by below way
    a) Use FM 'RSPO_DISPLAY_SPOOLJOB' providing the spool number,
    b) Use FM 'LIST_FROM_MEMORY' to get content from memory.
    c) Pass the content got by above FM to 'WWW_HTML_FROM_LISTOBJECT' to get the HTML content.
4) Now process using the CL_DOCUMENT_BCS, using the I_TYPE = html and I_TEXT = HTML content from above. 
Thanks & Regards
Bala Krishna.

Similar Messages

  • Send Smartform as Email body not PDF attachment

    Hello Experts,
    I have a requirement where I need to send Smartform as Email body and NOT as PDF attachment.
    I have spool ID generated for the smartform, how can I send this spool in Email body rather than as an attachment.

    Hi K C
    Try this.. Get the OTF data from the SMARTFORM, use the OTF data and pass this to FM'CONVERT_OTF', and use the format as PDF.
    Then use the resultant converted PDF data as attachment while calling the  'SO_NEW_DOCUMENT_ATT_SEND_API1' FM.
    let us know if this works.
    Thanks
    Rajesh Chowdary

  • Email Smartforms with Email Body

    Hello SAP Community,
    Sorry if my question has been asked before, but I did not find any answeres yet.
    I am using BO SOFMFOL and these FM to send my smartforms to external email:
    - CREATE_RECIPIENT_OBJ_PPF
    - CREATE_SENDER_OBJECT_PPF
    - SO_USER_AUTOMATIC_INSERT
    This is working fine.  My question is: How do you add an Email  Body?  I am on ECC 6.0.
    Appreciate any inputs on this issue.
    Many thanks,
    Kim

    Hi Kim,
    I had a requirement to convert the out put into PDF format and send an email using the function module SO_NEW_DOCUMENT_ATT_SEND_API1.
    I am providing my coding, hope it helps: 
    form SEND_EMAIL .
    DATA:   t_mailpack   TYPE sopcklsti1 OCCURS 0 WITH HEADER LINE,
              t_mailhead   TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailbin    TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailtxt    TYPE solisti1   OCCURS 0 WITH HEADER LINE,
              t_mailrec    TYPE somlreci1  OCCURS 0 WITH HEADER LINE.
      DATA: wa_maildata    TYPE sodocchgi1,
            l_filename(50) TYPE c,
            l_fldname(30)  TYPE c,
            l_fldval(100)  TYPE c,
            l_lines        TYPE i,
            l_text         TYPE text128 .
      DATA: w_email_subrc  TYPE i.
      DATA: w_ship like vbfa-vbeln.
      CLEAR: wa_maildata,
             t_mailtxt,
             t_mailbin,
             t_mailpack,
             t_mailhead,
             t_mailrec.
      REFRESH: t_mailtxt,
               t_mailbin,
               t_mailpack,
               t_mailhead,
               t_mailrec.
    *-- Fill output file
    *- Fill header
      CLEAR: t_mailbin.
    t_mailbin[] = pdf_tab[].
      t_mailbin[] = it_att[].     "Uthaman
    *This line is added to get the shipment no in Subject Line
    SELECT SINGLE * FROM vbfa WHERE vbelv EQ nast-objky
                                AND vbtyp_v EQ c_vbtyp_v_j
                                AND vbtyp_n EQ c_vbtyp_n_8.
    w_ship = vbfa-vbeln.
    shift w_ship left deleting leading '0'.
    *-- File name
    if nast-kschl EQ 'ZFPL'.
      CLEAR l_filename.
      CONCATENATE 'Packing List -'
                  sy-datum4(2) sy-datum6(2) sy-datum(4) '.PDF' INTO l_filename.
    *-- Creation of the document to be sent File Name
      wa_maildata-obj_name = 'Packing List'.
    *-- Mail Subject
      CONCATENATE l_filename '-' 'Shipment No -' w_ship INTO wa_maildata-obj_descr SEPARATED BY space.
    *-- Mail Contents
      t_mailtxt-line = 'Packing List'.
      APPEND t_mailtxt.
    ENDIF.
    if nast-kschl EQ 'ZFBA'.
      CLEAR l_filename.
      CONCATENATE 'Booking Advice -'
                  sy-datum4(2) sy-datum6(2) sy-datum(4) '.PDF'
                  INTO l_filename.
    *-- Creation of the document to be sent File Name
      wa_maildata-obj_name = 'Booking Advice'.
    *-- Mail Subject
      CONCATENATE l_filename '-' 'Shipment No -' w_ship INTO wa_maildata-obj_descr SEPARATED BY space.
    *-- Mail Contents
      t_mailtxt-line = 'Packing List'.
      APPEND t_mailtxt.
    ENDIF.
    *-- Prepare Packing List
    *-- Write Packing List (Main Subject)
      CLEAR: l_lines, t_mailpack.
      DESCRIBE TABLE t_mailtxt LINES l_lines.
    READ TABLE t_mailtxt INDEX l_lines.
      t_mailpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( t_mailtxt ).
    CLEAR t_mailpack-transf_bin.
      t_mailpack-transf_bin = ' '.
      t_mailpack-head_start = 1.
      t_mailpack-head_num = 0.
      t_mailpack-body_start = 1.
      t_mailpack-body_num = l_lines.
      t_mailpack-doc_type = 'RAW'.
      APPEND t_mailpack.
      t_mailhead = l_filename.
      APPEND t_mailhead.
    *-- Write Packing List (Attachment)
      CLEAR: l_lines, t_mailpack.
      DESCRIBE TABLE pdf_tab[] LINES l_lines.
    READ TABLE pdf_tab INDEX l_lines.
      t_mailpack-doc_size = ( l_lines - 1 ) * 255 + STRLEN( t_mailbin ).
      t_mailpack-transf_bin = 'X'.
      t_mailpack-head_start = 1.
      t_mailpack-head_num = 1.
      t_mailpack-body_start = 1.
      t_mailpack-body_num = l_lines.
      t_mailpack-doc_type = 'PDF'.
      t_mailpack-obj_name = l_filename.
      t_mailpack-obj_descr = l_filename.
      t_mailpack-obj_langu = 'E'.
      APPEND t_mailpack.
    *-- Set recipients
    tables :  ztotcemail.
    SELECT SINGLE * FROM vbfa WHERE vbelv EQ nast-objky
                                AND vbtyp_v EQ c_vbtyp_v_j
                                AND vbtyp_n EQ c_vbtyp_n_8.
    CLEAR vttk.
    SELECT SINGLE * FROM vttk WHERE tknum EQ vbfa-vbeln.
    SELECT SINGLE * FROM ztotcemail WHERE tplst = vttk-tplst
                                      AND lifnr = vttk-tdlnr.
    IF SY-SUBRC EQ 0.
      t_mailrec-receiver = ztotcemail-smtp_addr. .
      t_mailrec-rec_type  = 'U'.
      APPEND t_mailrec.
    ENDIF.
    **-- Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_maildata
          put_in_outbox              = 'X'
         commit_work                = 'X'  " N-16
        TABLES
          packing_list               = t_mailpack
          object_header              = t_mailhead
          contents_bin               = t_mailbin[]
          contents_txt               = t_mailtxt[]
          receivers                  = t_mailrec
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      w_email_subrc = sy-subrc.
      IF sy-subrc EQ 0.
        MESSAGE s000(zotc) WITH 'Email output sent successfully'.
      ELSE.
        MESSAGE s000(zotc) WITH 'Can not send email output'.
      ENDIF.
    endform.                    " SEND_EMAIL
    Regards,
    Kittu

  • Send SmartForm as Email Body

    Hi All!
    I need to send a SmarForm by email as an email body.
    The SmartForm is a simple plain text form.
    Does someone know how to do it?
    Regards,
    Alejandro.

    hi,
    try this link u will have two codes.
    Email Body
    even if u dont understand check this code.
    Here is the code to send the Smartform to mail as PDF attachment.
    REPORT ZTEST_PDF_MAIL.
    Internal Table declarations
    DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
    I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
    I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
    I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    Objects to send mail.
    I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
    I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
    Work Area declarations
    WA_OBJHEAD TYPE SOLI_TAB,
    W_CTRLOP TYPE SSFCTRLOP,
    W_COMPOP TYPE SSFCOMPOP,
    W_RETURN TYPE SSFCRESCL,
    WA_DOC_CHNG TYPE SODOCCHGI1,
    W_DATA TYPE SODOCCHGI1,
    WA_BUFFER TYPE STRING, "To convert from 132 to 255
    Variables declarations
    V_FORM_NAME TYPE RS38L_FNAM,
    V_LEN_IN LIKE SOOD-OBJLEN,
    V_LEN_OUT LIKE SOOD-OBJLEN,
    V_LEN_OUTN TYPE I,
    V_LINES_TXT TYPE I,
    V_LINES_BIN TYPE I.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    FORMNAME = 'ZTEST'
    IMPORTING
    FM_NAME = V_FORM_NAME
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    W_CTRLOP-GETOTF = 'X'.
    W_CTRLOP-NO_DIALOG = 'X'.
    W_COMPOP-TDNOPREV = 'X'.
    CALL FUNCTION V_FORM_NAME
    EXPORTING
    CONTROL_PARAMETERS = W_CTRLOP
    OUTPUT_OPTIONS = W_COMPOP
    USER_SETTINGS = 'X'
    IMPORTING
    JOB_OUTPUT_INFO = W_RETURN
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5.
    IF SY-SUBRC 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    I_OTF] = W_RETURN-OTFDATA[.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    FORMAT = 'PDF'
    MAX_LINEWIDTH = 132
    IMPORTING
    BIN_FILESIZE = V_LEN_IN
    TABLES
    OTF = I_OTF
    LINES = I_TLINE
    EXCEPTIONS
    ERR_MAX_LINEWIDTH = 1
    ERR_FORMAT = 2
    ERR_CONV_NOT_POSSIBLE = 3
    OTHERS = 4.
    IF SY-SUBRC 0.
    ENDIF.
    LOOP AT I_TLINE.
    TRANSLATE I_TLINE USING '~'.
    CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
    ENDLOOP.
    TRANSLATE WA_BUFFER USING '~'.
    DO.
    I_RECORD = WA_BUFFER.
    APPEND I_RECORD.
    SHIFT WA_BUFFER LEFT BY 255 PLACES.
    IF WA_BUFFER IS INITIAL.
    EXIT.
    ENDIF.
    ENDDO.
    Attachment
    REFRESH: I_RECLIST,
    I_OBJTXT,
    I_OBJBIN,
    I_OBJPACK.
    CLEAR WA_OBJHEAD.
    I_OBJBIN] = I_RECORD[.
    Create Message Body Title and Description
    I_OBJTXT = 'test with pdf-Attachment!'.
    APPEND I_OBJTXT.
    DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
    READ TABLE I_OBJTXT INDEX V_LINES_TXT.
    WA_DOC_CHNG-OBJ_NAME = 'smartform'.
    WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
    WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
    WA_DOC_CHNG-SENSITIVTY = 'F'.
    WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
    Main Text
    CLEAR I_OBJPACK-TRANSF_BIN.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    I_OBJPACK-BODY_NUM = V_LINES_TXT.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    APPEND I_OBJPACK.
    Attachment (pdf-Attachment)
    I_OBJPACK-TRANSF_BIN = 'X'.
    I_OBJPACK-HEAD_START = 1.
    I_OBJPACK-HEAD_NUM = 0.
    I_OBJPACK-BODY_START = 1.
    DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
    READ TABLE I_OBJBIN INDEX V_LINES_BIN.
    I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
    I_OBJPACK-BODY_NUM = V_LINES_BIN.
    I_OBJPACK-DOC_TYPE = 'PDF'.
    I_OBJPACK-OBJ_NAME = 'smart'.
    I_OBJPACK-OBJ_DESCR = 'test'.
    APPEND I_OBJPACK.
    CLEAR I_RECLIST.
    I_RECLIST-RECEIVER = 'mail id'.
    I_RECLIST-REC_TYPE = 'U'.
    APPEND I_RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    COMMIT_WORK = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    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.
    WRITE:/ 'Error When Sending the File', SY-SUBRC.
    ELSE.
    WRITE:/ 'Mail sent'.
    ENDIF.
    If you want to send some text as Body of the Mail then follow this once
    when u r callin the FM'SO_NEW_DOCUMENT_ATT_SEND_API1'.. points to remember
    1.u have to pass the body of content in table CONTENTS_TXT(ia m using I_OBJBIN) (each line a record) then. suppose i have appended 11 records to the table CONTENTS_TXT .
    2.PACKING_LIST(iam usign I_OBJPACK) table u ahve to append a redord as follows
    I_OBJPACK-TRANSF_BIN = ' '.
    I_OBJPACK-HEAD_START = 000000000000001.
    I_OBJPACK-HEAD_NUM = 000000000000001.
    I_OBJPACK-BODY_START = 000000000000002
    I_OBJPACK-BODY_NUM = 000000000000010.
    I_OBJPACK-DOC_TYPE = 'RAW'.
    append I_OBJPACK-.
    by the above code system treat the first line in table I_OBJBIN as header and the 2nd line to 10 lines tread as body.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    DOCUMENT_DATA = WA_DOC_CHNG
    PUT_IN_OUTBOX = 'X'
    TABLES
    PACKING_LIST = I_OBJPACK
    OBJECT_HEADER = WA_OBJHEAD
    CONTENTS_BIN = I_OBJBIN
    CONTENTS_TXT = I_OBJTXT
    RECEIVERS = I_RECLIST
    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.
    reward me ig helpful.

  • Actions - Smartform in Email body

    Hey all,
    I have a peculiar client requirement. On triggering an action from the CRM system from transactions, i need to send an email containing a samrtform.
    I understand that the standard SAP pracitice is to send the smartform as an attachment to the email. But what my client wants is that the content of the smartform should come in the body of the email.
    Would this be possible? If yes, how? If its not possible, is there an work around solution for this?
    Please Help.
    Thanks.
    Julius

    I have not found a simple solution to this problem, other than below.
    Using fm SO_DOCUMENT_SEND_API1 . There are a ton of examples in the abap forums on using this fm. The fm documentation also has some ssample code.
    My approach has been to create my email message body as an html string.
    i.e.
    data: str type string,
             name_org1 type but000-name_org1.
    concatenate '<html><head></head><body><h3>Customer Name: '  name_org1 '
                       '</h3></body></html>
           into str.
    Then pass the html string into the fm as the message body. Not pretty but functional.

  • Smartforms as email body looses format

    Hi experts,
    I´m using Badi BBP_OUTPUT_CHANGE_SF to change standard Smartforms, and when I use parameter CV_SMARTFORM_MAIL to send my own form, I see the result on tr. SCOT without any of the Smartform font styles, and format; it´s only plain text there!
    Can anybody help me?
    Thanks a lot!
    Federico Alvarez

    Dear Pradeep,
    I really apreciate your help, thank you very much.
    However, none of this Notes where helpful since we already have implemented Support Package 13, which includes all of them (Notes have been available with SP 12 and previous).
    Regarding to the thread provided, I´m doing exactly that: just changing Smartform_mail parameter inside de Badi with my own form, and I get the Smartform data inside the mail body, but without any format or style: it´s like the whole Smartform were converted into plain text.
    Any idea? Am I not supposed to get the Samrtform with font formats and borders, etc, inside de mail body?
    The attached Smartform (which the system automatically converts into PDF) looks good. But the other one, as mail body, really sucks as plain text...
    Kind regards,
    Federico.

  • How to send smartform output in body of email?

    Hi all ,
    I have to send smartform output in body of email (not as an attachement in mail) .PLease help me in this regard.
    Thanks,
    Ananth S.

    Hi Ananth
    See these threads.
    [https://forums.sdn.sap.com/click.jspa?searchID=23497094&messageID=6889194]
    [https://forums.sdn.sap.com/click.jspa?searchID=23497094&messageID=6861330]
    [https://forums.sdn.sap.com/click.jspa?searchID=23497094&messageID=6855364]
    Regards
    Hareesh Menon

  • Clarification needed regarding Smartform to email attachment.

    Hi All,
    I have tried creating PDF file and save the same on to my local drive.It worked fine and then i tried to send pdf thru e-mail. I encountered error and the changed contents_hex to contents_bin in FM SO_NEW_DOCUMENT_ATT_SEND_API1. But i didnt receive the attachment to my id. Do we need to do any system settings for this. I didnt do any cofiguration settings. Please let me know incase of anything needs to be taken care of.
    Thanks,
    Udaya.

    hi,
    chk ur code with this sample code and compare.
    REPORT y_cb_test_051 .
    DATA DECLARATION
    TYPE-POOLS: meein.
    TABLES: toa_dara,
    nast,
    tnapr,
    arc_params.
    DATA: ent_retco TYPE sy-subrc,
    ent_screen TYPE c,
    l_xkomk LIKE TABLE OF komk WITH HEADER LINE,
    xscreen. "Kz. Probeausgabe
    DATA: i_texto_cuerpo LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    SELECT OPTIONS / PARAMETERS
    PARAMETERS:
    p_kappl LIKE nast-kappl OBLIGATORY DEFAULT 'EF',
    p_objky LIKE nast-objky OBLIGATORY DEFAULT '0010001125',
    p_kschl LIKE nast-kschl OBLIGATORY DEFAULT 'NEU',
    p_spras LIKE nast-spras OBLIGATORY DEFAULT 'EN',
    p_parnr LIKE nast-parnr OBLIGATORY DEFAULT '50009123',
    p_parvw LIKE nast-parvw OBLIGATORY DEFAULT 'BA',
    p_erdat LIKE nast-erdat OBLIGATORY DEFAULT '20050908',
    p_eruhr LIKE nast-eruhr OBLIGATORY DEFAULT '130105',
    p_aende LIKE nast-aende DEFAULT 'X',
    p_nacha LIKE nast-nacha DEFAULT '1',
    p_ndialo TYPE tdsfflag DEFAULT ' ',
    p_telfx LIKE nast-telfx DEFAULT '1-920-721-0284',
    p_tland LIKE nast-tland DEFAULT 'US',
    p_sform TYPE tdsfname DEFAULT 'ZMMNABPR3PFMMPO_L3' OBLIGATORY.
    *PDF TABLES
    DATA: tb_pdf LIKE tline OCCURS 0.
    DATA: tb_pdf255 TYPE so_text255 OCCURS 0.
    MAIN PROCESSING SECTION
    START-OF-SELECTION.
    SELECT SINGLE *
    INTO nast
    FROM nast
    WHERE kappl = p_kappl
    AND objky = p_objky
    AND kschl = p_kschl
    AND spras = p_spras
    AND parnr = p_parnr
    AND parvw = p_parvw
    AND erdat = p_erdat
    AND eruhr = p_eruhr.
    IF sy-subrc <> 0.
    MESSAGE s000(00) WITH 'Record in NAST not found.'.
    nast-kappl = p_kappl.
    nast-objky = p_objky.
    nast-kschl = p_kschl.
    nast-spras = p_spras.
    nast-parnr = p_parnr.
    nast-parvw = p_parvw.
    nast-erdat = p_erdat.
    nast-eruhr = p_eruhr.
    nast-nacha = p_nacha.
    nast-telfx = p_telfx.
    nast-tland = p_tland.
    ENDIF.
    nast-aende = p_aende.
    tnapr-sform = p_sform.
    PERFORM entry_neu
    USING
    ent_retco
    ent_screen.
    FORMS
    *& Form entry_neu
    text
    -->ENT_RETCO text
    -->ENT_SCREEN text
    FORM entry_neu
    USING
    ent_retco
    ent_screen.
    DATA: l_druvo LIKE t166k-druvo,
    l_nast LIKE nast,
    l_from_memory,
    l_doc TYPE meein_purchase_doc_print.
    DATA: ls_print_data_to_read TYPE lbbil_print_data_to_read.
    DATA: ls_bil_invoice TYPE lbbil_invoice.
    DATA: lf_fm_name TYPE rs38l_fnam.
    DATA: ls_control_param TYPE ssfctrlop.
    DATA: ls_composer_param TYPE ssfcompop.
    DATA: ls_recipient TYPE swotobjid.
    DATA: ls_sender TYPE swotobjid.
    DATA: lf_formname TYPE tdsfname.
    DATA: ls_addr_key LIKE addr_key.
    xscreen = ent_screen.
    clear ent_retco.
    IF nast-aende EQ space.
    l_druvo = '1'.
    ELSE.
    l_druvo = '2'.
    ENDIF.
    CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
    EXPORTING
    ix_nast = nast
    ix_screen = ent_screen
    IMPORTING
    ex_retco = ent_retco
    ex_nast = l_nast
    doc = l_doc
    CHANGING
    cx_druvo = l_druvo
    cx_from_memory = l_from_memory.
    CHECK ent_retco EQ 0.
    IF nast-adrnr IS INITIAL.
    PERFORM get_addr_key
    CHANGING ls_addr_key.
    ELSE.
    ls_addr_key = nast-adrnr.
    ENDIF.
    *Set the print Parameters
    PERFORM set_print_param USING ls_addr_key
    CHANGING ls_control_param
    ls_composer_param
    ls_recipient
    ls_sender
    ent_retco.
    *Get the Smart Form name.
    IF NOT tnapr-sform IS INITIAL.
    lf_formname = tnapr-sform.
    ELSE.
    lf_formname = tnapr-fonam.
    ENDIF.
    determine smartform function module for invoice
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
    formname = lf_formname
    IMPORTING
    fm_name = lf_fm_name
    EXCEPTIONS
    no_form = 1
    no_function_module = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    error handling
    ent_retco = sy-subrc.
    perform protocol_update_i.
    ENDIF.
    ls_control_param-getotf = 'X'.
    DATA: l_document_output_info TYPE ssfcrespd,
    l_job_output_info TYPE ssfcrescl,
    l_job_output_options TYPE ssfcresop.
    CALL FUNCTION lf_fm_name
    EXPORTING
    archive_index = toa_dara
    archive_parameters = arc_params
    control_parameters = ls_control_param
    mail_recipient = ls_recipient
    mail_sender = ls_sender
    output_options = ls_composer_param
    user_settings = ' '
    zxekko = l_doc-xekko
    zxpekko = l_doc-xpekko
    zxaend = l_doc-xaend
    IMPORTING
    document_output_info = l_document_output_info
    job_output_info = l_job_output_info
    job_output_options = l_job_output_options
    TABLES
    l_xekpo = l_doc-xekpo[]
    l_xekpa = l_doc-xekpa[]
    l_xpekpo = l_doc-xpekpo[]
    l_xeket = l_doc-xeket[]
    l_xtkomv = l_doc-xtkomv[]
    l_xekkn = l_doc-xekkn[]
    l_xekek = l_doc-xekek[]
    l_xaend = l_doc-xaend[]
    l_xkomk = l_xkomk
    EXCEPTIONS
    formatting_error = 1
    internal_error = 2
    send_error = 3
    user_canceled = 4
    OTHERS = 5.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno.
    BREAK-POINT.
    ENDIF.
    Converts OTF to PDF
    DATA: v_len_in TYPE i.
    CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
    format = 'PDF'
    max_linewidth = 132
    IMPORTING
    bin_filesize = v_len_in
    TABLES
    otf = l_job_output_info-otfdata
    lines = tb_pdf
    EXCEPTIONS
    err_max_linewidth = 0
    err_format = 1
    err_conv_not_possible = 2
    OTHERS = 3.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Change the PDF format from 132 to 255.
    CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
    EXPORTING
    line_width_src =
    line_width_dst =
    transfer_bin = 'X'
    TABLES
    content_in = tb_pdf
    content_out = tb_pdf255
    EXCEPTIONS
    err_line_width_src_too_long = 1
    err_line_width_dst_too_long = 2
    err_conv_failed = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    DATA: lw_subject TYPE so_obj_des.
    DATA: lwa_body TYPE solisti1.
    DATA: ltb_body TYPE TABLE OF solisti1.
    DATA: lw_filename TYPE char100.
    DATA: ltb_recipients TYPE TABLE OF somlreci1.
    DATA: lwa_recipients TYPE somlreci1.
    lw_subject = 'This is the email subject'.
    lwa_body-line = 'This is the email body - Line1'.
    APPEND lwa_body TO ltb_body.
    lwa_body-line = 'This is the email body - Line2'.
    APPEND lwa_body TO ltb_body.
    lwa_body-line = 'This is the email body - Line3'.
    APPEND lwa_body TO ltb_body.
    lwa_body-line = 'This is the email body - Line4'.
    APPEND lwa_body TO ltb_body.
    lw_filename = 'Contract'.
    *RECIPIENTS
    lwa_recipients-rec_type = 'U'.
    lwa_recipients-express = 'X'.
    lwa_recipients-receiver = sy-uname.
    lwa_recipients-copy = ''.
    APPEND lwa_recipients TO ltb_recipients.
    RECIPIENTS
    lwa_recipients-rec_type = 'U'.
    lwa_recipients-express = 'X'.
    lwa_recipients-receiver = '[email protected]'.
    lwa_recipients-copy = ''.
    APPEND lwa_recipients TO ltb_recipients.
    RECIPIENTS
    lwa_recipients-rec_type = 'U'.
    lwa_recipients-express = 'X'.
    lwa_recipients-receiver = '[email protected]'.
    lwa_recipients-copy = ''.
    APPEND lwa_recipients TO ltb_recipients.
    Sends the PDF by email.
    PERFORM f_send_pdf_by_email
    TABLES
    tb_pdf255
    ltb_body
    ltb_recipients
    USING
    lw_subject
    lw_filename.
    ENDFORM. "entry_neu
    *& Form ZCA_MAIL_BIN
    text
    FORM f_send_pdf_by_email
    TABLES
    ptb_pdf255 STRUCTURE solisti1
    ptb_body STRUCTURE solisti1
    ptb_recipients STRUCTURE somlreci1
    USING
    pw_subject TYPE so_obj_des
    pw_filename TYPE char100.
    *-DATA DECLARATION----
    Variables y tablas internas.
    DATA: BEGIN OF ltb_objbin OCCURS 0.
    INCLUDE STRUCTURE solisti1.
    DATA: END OF ltb_objbin.
    DATA: lwa_doc_chng LIKE sodocchgi1,
    lw_tab_lines LIKE sy-tabix,
    ltb_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    ltb_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    *-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.
    COMMIT WORK.
    ENDFORM. "ZCA_MAIL_BIN
    *& Form get_addr_key
    text
    -->P_CS_BIL_INVOICE_HD_ADR text
    <--P_CS_ADDR_KEY text
    FORM get_addr_key
    CHANGING l_addr_key LIKE addr_key.
    DATA: l_lfa1 LIKE lfa1.
    SELECT SINGLE * FROM lfa1 INTO l_lfa1
    WHERE lifnr = nast-parnr.
    IF sy-subrc = 0.
    MOVE l_lfa1-adrnr TO l_addr_key.
    ENDIF.
    ENDFORM. " get_addr_key
    *& Form set_print_param
    text
    -->P_LS_ADDR_KEY text
    <--P_LS_CONTROL_PARAM text
    <--P_LS_COMPOSER_PARAM text
    <--P_LS_RECIPIENT text
    <--P_LS_SENDER text
    <--P_CF_RETCODE text
    FORM set_print_param USING is_addr_key LIKE addr_key
    CHANGING cs_control_param TYPE ssfctrlop
    cs_composer_param TYPE ssfcompop
    cs_recipient TYPE swotobjid
    cs_sender TYPE swotobjid
    cf_retcode TYPE sy-subrc.
    DATA: ls_itcpo TYPE itcpo.
    DATA: lf_repid TYPE sy-repid.
    DATA: lf_device TYPE tddevice.
    DATA: ls_recipient TYPE swotobjid.
    DATA: ls_sender TYPE swotobjid.
    lf_repid = sy-repid.
    CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
    CALL FUNCTION 'Z_MMNA_WFMC_PREPARE_SMART_FORM'
    EXPORTING
    pi_nast = nast
    pi_addr_key = is_addr_key
    pi_repid = lf_repid
    IMPORTING
    pe_returncode = cf_retcode
    pe_itcpo = ls_itcpo
    pe_device = lf_device
    pe_recipient = cs_recipient
    pe_sender = cs_sender.
    IF cf_retcode = 0.
    MOVE-CORRESPONDING ls_itcpo TO cs_composer_param.
    cs_composer_param-tdimmed = ' '.
    cs_control_param-device = lf_device.
    cs_control_param-no_dialog = 'X'.
    cs_control_param-no_dialog = p_ndialo.
    cs_control_param-preview = xscreen.
    cs_control_param-getotf = ls_itcpo-tdgetotf.
    cs_control_param-langu = nast-spras.
    ENDIF.
    ENDFORM. "set_print_param
    rgds
    anver
    if helped rwrd points

  • EMAIL BODY SAME AS ATTACHMENT

    Hi All,
    Currently I am sending email with PDF attachement. I want to send the email body same as PDF attachement.
    Can give me any FM name to onvert SMARTFORM into HTML to paste in email body.
    Arun Prasad

    Thank you for reply Krishnan.
    But I believe some FM should be ther to convert SMart form to HTML content. I found SO_OBJECT_SEND FM for adding fixed text in email body which can use HTML format also.
    I need another FM to convert SMARTFORM to HTML,later I can use above mentioned FM for embedded in email body.
    Arun Prasad

  • Junk characters in email body only for specific user IDs

    While sending mail from SAP I am using
            SENDER = CL_SAPUSER_BCS=>CREATE( LV_SENDER_ADD ).
            CALL METHOD SEND_REQUEST->SET_SENDER
              EXPORTING
                I_SENDER = SENDER.
    now while using 'User1' and 'User2'  in LV_SENDER_ADD give a perfect result.
    But while using 'User3' and 'User4' in LV_SENDER_ADD sends Junk chars in the email body
    ST05 Trace Results show below mention lines in red.
    hh:mm:ss:ms       Type        Lasts(us)       Object                 Text                                           
    19:05:07:451      CMOD          - - -         rstscb_call_back       Parameter:                                                                         
    19:05:07:451      CMOD         - - -        rstswsf_was_stor      Parameter:                                                                         
    19:05:07:451      CMOD              2       rstswsf_was_stor      Parameter:                          Comment:   Returncode: 0                       
    19:05:07:451      CMOD              9       rstscb_call_back      Parameter:                          Comment:   Returncode: 0                       
    19:05:07:451      CMOD         - - -        rscpi_init            Parameter:                                                                         
    (I am converting the XSF output of Smartform  and SCP_TRANSLATE_CHARS to translate smartform output into HTML)
    all the above four user have SAP_ALL authorization.
    'user4' is created as a copy of 'user1'
    Checking the Type CMOD says that they are call to 'C' routine 'kernal calls'
    the above code is executed withe the user id of user1 2 3 4  and all of them give the same results.
    when ever the sender is user1 or user2 the transmission is successful else. sends junk chars.

    Could you tell us why/how you use SCP_TRANSLATE_CHARS?
    Do theseusers have same language/country in their profile?

  • Attach text from SODIS into the email body

    Hello Experts,
    I am working on a requirement wherein I am sending the output of a smartform in PDF format via email to the users.Also , the disclosure from SODIS is also required to be attached as a body of the email.
    Unfortunately , I was not able to do this task. The email functionality works correctly but the disclosure text is not getting attached in the body.
    Can anyone guide me step by step for this ?
    Regards,
    Neeraj.

    Hi Neeraj,
    Once you have defined the text in SODIS, you have to select Settings icon from the tree menu. There are three options available:
    Disclosures always appended
    Application-driven
    Inactive
    Select "Disclosures always appended" and this will ensure that the email is always accompanied by the disclosures. Save. Execute SCOT and open Settings Folder. Double click on settings node and the settings screen will open on the right. In the tab Outbound Settings, in screen Main Document, check box to activate First body part must be text. Save. Send an email, it will now include email body.
    Regards,
    Harriet

  • Creating email body  while generating output type as email.

    Hi All,
        I wanna create an email body while sending email through output type for smartform.
        I am successfully creating a mail with attachement. But requirement ned to send a body with same email..
        can any one know the same pls share. its very urgent... thx
    Thanks..

    Hello,
    declare the following
    data :
    i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    in the program write the below cod as following
    i_objtxt = 'Find attached the output of the smart form.'. --> this is the body of the mail.
    APPEND i_objtxt.
    now pass this to the call function.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = w_doc_chng
            put_in_outbox              = 'X'
          IMPORTING
            sent_to_all                = v_sent_all
          TABLES
            packing_list               = i_objpack ......
    This shall trigger the body.

  • Sending smartform through email as PDF attachment

    Hi,
    I want to send a smartform through email as pdf attachment.In the code I have hardcoded the receiver mail id.But I don't want this to be sent only to a particular receiver.I want this to be sent as many people as I can without hardcoding their mail id's in the program.How can I do that?
    Regards,
    Hema

    **Data Declarations
    **Internal Table
    DATA : BEGIN OF it_spfli OCCURS 0,
              carrid LIKE spfli-carrid,
              connid LIKE spfli-connid,
           END OF it_spfli.
    DATA:   it_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            it_contents     LIKE solisti1 OCCURS 0 WITH HEADER LINE,
    storing receivers      
            it_receivers    LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
    **storing file attachment data
            it_attachment   LIKE solisti1 OCCURS 0 WITH HEADER LINE,                    gd_doc_data     LIKE sodocchgi1,
            gd_error        TYPE sy-subrc,
            l_gntxt         LIKE t357g_t-gntxt,
            lv_message(100) TYPE c.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE. "storing mail body
    DATA : psubject(30) TYPE c VALUE 'Sample Mail'. "subject of the mail
    DATA : ld_format TYPE so_obj_tp , "file format
           ld_attfilename TYPE so_obj_des, "file name
           w_cnt TYPE i.
    **Selecting the data
    SELECT carrid connid INTO TABLE it_spfli FROM spfli WHERE carrid EQ 'AA'.
    **Perform for populating mail body
    PERFORM populate_message.
    **Perform for populating file attachment
    PERFORM populate_attachment.
    **Perform for populating mail characteristic info
    PERFORM populate_pack.
    **Perform for populating receivers
    PERFORM populate_receivers.
    **Perform to send mail
    PERFORM send_mail.
    *&      Form  populate_message
          text
    -->  p1        text
    <--  p2        text
    FORM populate_message .
    **Populating the body
      lv_message = 'Sample mail for testing purpose.'.
      APPEND lv_message TO it_message.
    ENDFORM.                    " populate_message
    *&      Form  populate_attachment
          text
    -->  p1        text
    <--  p2        text
    FORM populate_attachment .
    **Populating the attachment file with the data from final intenal table
      CONCATENATE 'CARRIER ID'
                  'CONNECTION ID'
                  INTO it_attachment SEPARATED BY
                  cl_abap_char_utilities=>horizontal_tab.
      CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO
      it_attachment.
      APPEND it_attachment.
      LOOP AT it_spfli.
        CONCATENATE it_spfli-carrid it_spfli-connid INTO it_attachment SEPARATED BY
                 cl_abap_char_utilities=>horizontal_tab.
        CONCATENATE cl_abap_char_utilities=>cr_lf it_attachment INTO
        it_attachment.
        APPEND it_attachment.
      ENDLOOP.
    ENDFORM.                    " populate_attachment
    *&      Form  populate_receivers
          text
    -->  p1        text
    <--  p2        text
    FORM populate_receivers .
    **Populating Mail Recepients
    **If there are more than one mail recepient then loop and append them to it_receivers
      it_receivers-receiver = '[email protected]'.
      it_receivers-rec_type = 'U'.
      it_receivers-com_type = 'INT'.
      it_receivers-notif_del = 'X'.
      it_receivers-notif_ndel = 'X'.
      it_receivers-express = 'X'.
      APPEND it_receivers.
    ENDFORM.                    " populate_receivers
    *&      Form  populate_pack
          text
    -->  p1        text
    <--  p2        text
    FORM populate_pack .
    **File Type
      ld_format = 'XLS'.
    **File Name
      ld_attfilename = 'File1'.
    Fill the document data.
      gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      gd_doc_data-obj_name = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject .
      gd_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR gd_doc_data.
    Populate the subject/generic message attributes
      gd_doc_data-obj_langu = sy-langu.
      READ TABLE it_attachment INDEX w_cnt.
      gd_doc_data-doc_size = ( w_cnt - 1 ) * 255 + STRLEN( it_attachment ).
      gd_doc_data-obj_name  = 'SAPRPT'.
      gd_doc_data-obj_descr = psubject.
      gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
      CLEAR it_packing_list.
      REFRESH it_packing_list.
      it_packing_list-transf_bin = space.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 0.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES it_packing_list-body_num.
      it_packing_list-doc_type = 'RAW'.
      APPEND it_packing_list.
    **Describe the attachment info
      it_packing_list-transf_bin = 'X'.
      it_packing_list-head_start = 1.
      it_packing_list-head_num = 1.
      it_packing_list-body_start = 1.
      DESCRIBE TABLE it_attachment LINES  it_packing_list-body_num.
      it_packing_list-doc_type = ld_format.
      it_packing_list-obj_name = ld_attfilename.
      it_packing_list-obj_descr = ld_attfilename.
      it_packing_list-doc_size = it_packing_list-body_num * 255.
      APPEND it_packing_list.
    ENDFORM.                    " populate_pack
    *&      Form  send_mail
          text
    -->  p1        text
    <--  p2        text
    FORM send_mail .
    **Function Module to send mail
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = gd_doc_data
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_packing_list
          contents_bin               = it_attachment
          contents_txt               = it_message
          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.
    ENDFORM.                    " send_mail

  • Smartforms thru EMAIL

    Hi frnds,
    how to send the smartforms thru email?
    please send me the documents or links or materials to my id.
    [email protected]
    thanks in advance.
    Regards,
    Balu

    Hi Reddy,
    Use 'SO_NEW_DOCUMENT_SEND_API1 F.M
    Please go through the code.
    data declaration
    c_u(1)            VALUE 'U',      "Value U
    c_int(3)          VALUE 'INT',    "Value Int
    c_saprpt(6)       VALUE 'SAPRPT', "Heading
    c_f(1)            VALUE 'F',      "Value F
    c_raw(3)          VALUE 'RAW'.    "Doc Type
    getting the data from TVARV
    CONCATENATE  'CBSI_FILE_NAME' '0227' INTO l_var_name SEPARATED BY '_'.
      CALL FUNCTION 'Z_GET_TVARV_ENTRIES'
        EXPORTING
          i_name            = l_var_name
          i_type            = 'P'
      I_MSGTY           =
       IMPORTING
          e_parameter       = l_file.
    TABLES
       t_tvarv           =
      p_file = l_file .
    Sending email
      PERFORM send_file_as_email_attachment
              USING v_email
                    'SM0003 Control Total Data'
                    'SM0003 Control Total Data'
          Send email
         -->P_GV_EMAIL   Email id
         -->P_TEXT_003   Subject
         -->P_TEXT_003   Subject
         -->P_6200       text
    FORM send_file_as_email_attachment
                               USING p_email      TYPE somlreci1-receiver
                                 p_mtitle         TYPE sodocchgi1-obj_descr
                                 p_filename       TYPE so_obj_des
                                 p_attdescription TYPE so_obj_nam.
    *Local varibales
      DATA: lv_mtitle           TYPE sodocchgi1-obj_descr,
            lv_email            TYPE  somlreci1-receiver,
            lv_attdescription   TYPE  so_obj_nam ,
            lv_attfilename      TYPE  so_obj_des ,
            lv_sent_all         TYPE  sonv-flag.
    *move values
      it_attach[] = it_output[].
      lv_sent_all = c_x.
      lv_email   = p_email.
      lv_mtitle  = p_mtitle.
      lv_attdescription      = p_attdescription.
      lv_attfilename         = p_filename.
    Fill the document data.
      it_docchange-doc_size = 1.
    Populate the subject/generic message attributes
      it_docchange-obj_langu = sy-langu.
      it_docchange-obj_name  = c_saprpt.
      it_docchange-obj_descr = lv_mtitle .
      it_docchange-sensitivty = c_f.
    Fill the document data and get size of attachment
      READ TABLE it_attach
           INDEX v_chr_entries
    TRANSPORTING NO FIELDS.
      it_docchange-doc_size =
         ( v_chr_entries - 1 ) * 255 + STRLEN( it_attach ).
      it_docchange-obj_langu  = sy-langu.
      it_docchange-obj_name   = c_saprpt.
      it_docchange-obj_descr  = lv_mtitle.
      it_docchange-sensitivty = c_f.
    Describe the body of the message
      CLEAR wa_objpack.
      REFRESH it_objpack.
      wa_objpack-transf_bin = space.
      wa_objpack-head_start = 1.
      wa_objpack-head_num = 0.
      wa_objpack-body_start = 1.
      DESCRIBE TABLE it_message LINES v_objpackbody.
      wa_objpack-doc_type = c_raw.
      APPEND wa_objpack
          TO it_objpack.
    Create attachment notification
      wa_objpack-transf_bin = c_x.
      wa_objpack-head_start = 1.
      wa_objpack-head_num   = 1.
      wa_objpack-body_start = 1.
      DESCRIBE TABLE it_attach LINES v_objpackbody.
      wa_objpack-obj_descr  =  lv_attdescription.
      wa_objpack-obj_name   =  lv_attfilename.
      wa_objpack-doc_size   =  wa_objpack-body_num * 255.
      APPEND wa_objpack
          TO it_objpack.
    Add the recipients email address
      REFRESH it_reclist.
      LOOP AT it_mailid .
        wa_reclist-receiver = it_mailid-low.
    wa_reclist-receiver = '[email protected]'.
        wa_reclist-rec_type = c_u.
        wa_reclist-com_type = c_int.
        wa_reclist-notif_del = c_x.
        wa_reclist-notif_ndel = c_x.
        APPEND wa_reclist
         TO it_reclist.
        CLEAR wa_reclist.
      ENDLOOP.
      IF 1 = 2.
      ENDIF.
      CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = it_docchange
                document_type              = c_raw
                put_in_outbox              = c_x
               commit_work                = c_x
           IMPORTING
                sent_to_all                = lv_sent_all
           TABLES
                object_content             = it_attach
                receivers                  = it_reclist
           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 e114 ."Unable to send An Email with Session Log.
      ENDIF.      "IF sy-subrc NE 0.
    ENDFORM.                    "send_file_as_email_attachment
    Thanks & Regards,
    Padmaja

  • Forms as Email body

    Hello,
    Is it possible to send a Adobe form as a email body and not as attachment? I know it is possible with smartforms. I am interested to know if it is also possible with ADOBE forms
    Dose anyone have some solution?
    Thanks.

    Hi
    The PDF file generated is available in the parameter fp_formoutput which is returned by the generated function module.
    call function fm_name
    exporting
    /1bcdwb/docparams = fp_docparams
    Z_VNDBNK             = wa_vndbnk
    importing
    /1BCDWB/FORMOUTPUT = fp_formoutput.
    The next step would be to extract this PDF and send it using BCS.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
    buffer         = fp_formoutput-PDF               "PDF file from function module
    TABLES
    binary_tab  = lt_att_content_hex.
    Add your PDF content lt_att_content_hex to Mail body as you do in Smartforms
    You can use 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send the mail or use Objects to send the mail as below.
    CLASS cl_bcs DEFINITION LOAD.
    DATA:
    lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    lo_send_request = cl_bcs=>create_persistent( ).
    ***Message body and subject
    DATA:
    lt_message_body TYPE bcsy_text VALUE IS INITIAL,
    lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
    Add your PDF content lt_att_content_hex to lt_message_body
    lo_document = cl_document_bcs=>create_document(
    i_type = 'RAW'
    i_text = lt_message_body
    i_subject = 'Vendor Payment Form' ).

Maybe you are looking for