Email smartform

Hi All,
I have a requirement to email one smartform as a PDF attachment, and another smartform in the body of a mail.
Currently, the settings in SCOT is that smartform will be sent out as PDF.
Can I know where and how I can manually code to make the smartform be sent in the body of a mail? Thks...
PS: Or could this be done by config through email action configuration?

Sorry, let me rephrase. I saw the following post, and I was wondering where I could populate the TEXT document type as mentioned by Sharif. According to Sharif, it can be done, and according to the person who started the following thread, it seems that Sharif's way works.
Hope the above is clear
<i>Ramachandran Si...  
Posts: 8
Questions: 2
Registered: 3/23/06
Forum points: 0 
   Doubt with usage of SMTP in actions ??  
Posted: Sep 4, 2007 1:53 PM       Reply      E-mail this post 
We have multiple actions configured in the system for outgoing email and the SMTP setting in SCOT is setup to be PDF's....How can i configure actions so that few of the outgoing emails can be TXT and others to be PDF's ?
Sharifuddin Ina...  
Posts: 262
Questions: 0
Registered: 7/24/07
Forum points: 568 
   Re: Doubt with usage of SMTP in actions ??   
Posted: Sep 4, 2007 5:49 PM    in response to: Ramachandran Si...       Reply      E-mail this post 
Hi,
This can be achieved by copying the Action Class to a Z class and modify the Method used by the action.
In this mthod you pass the Document Type as TEXT to the FM that sends the EMAIL.
i hope this works
Kindly reward with points in case helpful
Sharif
Ramachandran Si...  
Posts: 8
Questions: 2
Registered: 3/23/06
Forum points: 0 
   Re: Doubt with usage of SMTP in actions ??  
Posted: Sep 12, 2007 11:26 AM    in response to: Sharifuddin Ina...       Reply      E-mail this post 
This works , Thanks !
</i>

Similar Messages

  • Error In emailing smartforms

    I am trying to email my smartform output to a specified email address, but I am getting an error messege as mail could not me send as in the function module 'SO_NEW_DOCUMENT_SEND_API1'
    Below is the code. The smartform contains a logo only.
    Pls see the code and tell me what isn that I am missing!
    *& Report  ZKHA_SMARTFORM
    REPORT  zkha_smartform.
    TYPE-POOLS: slis,
                abap.
    DATA  : BEGIN OF it_mara OCCURS 0,
            matnr LIKE mara-matnr,
            END OF it_mara.
    DATA: wa_ctrlop TYPE ssfctrlop,  "Smart Forms: Control structure
          wa_outopt TYPE ssfcompop,  " SAP Smart Forms: Smart Composer (transfer)
          t_otfdata TYPE ssfcrescl,  "Smart Forms: Return value at end of form Printing
          t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,       "#EC *
          t_otf TYPE itcoo OCCURS 100 WITH HEADER LINE,"#EC * "itcoo is OTF Struct
          w_filesize TYPE i,                                    "#EC *
          w_bin_filesize TYPE i,                                "#EC NEEDED
          fm_name TYPE rs38l_fnam.
    DATA : fullpath              TYPE string,                   "#EC *
           filename              TYPE string,                   "#EC *
           path                  TYPE string,                   "#EC *
           user_action           TYPE i,                        "#EC *
           encoding              TYPE abap_encoding.            "#EC *
    PARAMETERS: p_file TYPE rlgrap-filename NO-DISPLAY.
    DATA: numbytes TYPE i,
    cancel.
    *wa_outopt-tddest = ' '.
    wa_ctrlop-getotf = 'X'.
    wa_ctrlop-no_dialog = 'X'.
    *wa_outopt-tdnoprev = 'X'.
    *wa_outopt-tdnoprint = 'X'.                    " CHANGED HERE
    *wa_ctrlop-device = 'MAIL'.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        formname                 = 'Z_KHATEST1'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       fm_name                  =  fm_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.
    CALL FUNCTION  fm_name
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
      control_parameters         = wa_ctrlop                       " CHANGED HERE
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
      output_options             = wa_outopt                     " CHANGED HERE
      user_settings              = 'X'
    IMPORTING
      DOCUMENT_OUTPUT_INFO       =
          job_output_info            = t_otfdata
      JOB_OUTPUT_OPTIONS         =
    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.
    *CASE sy-ucomm.
    WHEN 'PRNT'.                                         " ADDED HERE
        t_otf[] = t_otfdata-otfdata[].
        CALL FUNCTION 'CONVERT_OTF'
         EXPORTING
           format                      = 'PDF'
           max_linewidth               = 132
      ARCHIVE_INDEX               = ' '
      COPYNUMBER                  = 0
      ASCII_BIDI_VIS2LOG          = ' '
      PDF_DELETE_OTFTAB           = ' '
         IMPORTING
           bin_filesize                = w_bin_filesize
      BIN_FILE                    =
          TABLES
            otf                         = t_otf
            lines                       = t_pdf_tab
         EXCEPTIONS
           err_max_linewidth           = 1
           err_format                  = 2
           err_conv_not_possible       = 3
           err_bad_otf                 = 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.
    Data: t_objbin type standard table of  SOLISTI1 with header line.
          Converted to length of 255 Char
    CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
    EXPORTING
      LINE_WIDTH_SRC                    =
       LINE_WIDTH_DST                    =  '255'
      TRANSFER_BIN                      = ' '
      TABLES
        content_in                        = t_pdf_tab
        content_out                       = t_objbin
    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.
        PERFORM download_w_ext(rstxpdft) TABLES t_pdf_tab
                                         USING p_file
                                               '.pdf'
                                                'BIN'
                                               numbytes
                                               cancel.          "#EC *
       CLEAR: wa_outopt, wa_ctrlop.
    *ENDCASE.
    DATA:
            t_tline     TYPE TABLE OF tline,
            t_reclist   TYPE TABLE OF somlreci1,
            wa_doc_chng TYPE          sodocchgi1,
            wa_reclist  TYPE          somlreci1,
            wa_return   TYPE          ssfcrescl,
            v_descr     TYPE          so_obj_des,
            v_mailid    TYPE          ad_smtpadr,
            v_adrnr     TYPE          ad_addrnum ,
            v_len_in    TYPE          string.
              wa_doc_chng-obj_name   = 'SMARTFORM'.
              wa_doc_chng-expiry_dat =  sy-datum + 10.
             wa_doc_chng-obj_descr  =  v_descr.
              wa_doc_chng-sensitivty = 'F'.
              wa_doc_chng-obj_langu  =  sy-langu.
              wa_doc_chng-no_change  = 'X' .
            Selecting email address depending on
            address no.from ADR6 Table
             SELECT smtp_addr                         "E-Mail Address
             FROM   adr6      UP TO 1 ROWS
             INTO   v_mailid
             WHERE  addrnumber = v_adrnr.
             ENDSELECT .
             wa_reclist-receiver = v_mailid.
              wa_reclist-receiver = '[email protected]'. 
              " I have hard coded the mail address. It is automatically populating the adr6 table, I donno why???
    Pls give immediate resolution!!!!
              wa_reclist-rec_type = 'U'.
              APPEND wa_reclist  TO t_reclist.
    break-point.
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
      EXPORTING
        document_data                    = wa_doc_chng
       DOCUMENT_TYPE                    = 'PDF'
       PUT_IN_OUTBOX                    = 'X'
       COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
      tables
      OBJECT_HEADER                    =
       OBJECT_CONTENT                   = t_objbin
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
        receivers                        = t_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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    Use the following steps for doing the same. These steps are tested succesfully.
    1.  Get the Function Module Name for the Smart form
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
         EXPORTING
           formname                 = c_fmname
         VARIANT                  = ' '
         DIRECT_CALL              = ' '
         IMPORTING
           FM_NAME                  = w_fmname
         EXCEPTIONS
           NO_FORM                  = 1
           NO_FUNCTION_MODULE       = 2
           OTHERS                   = 3
    2. Set the values to be passed in the Function Module to get the output of the Smart form in OTF format.
    Set the call for OTF format.
      t_control_parameters-no_dialog = c_x.
      t_control_parameters-getotf = c_x.
    3. Call the function Module for the smartform.
    CALL FUNCTION w_fmname
        EXPORTING
          ARCHIVE_INDEX              = H_ARCHIVE_INDEX
        ARCHIVE_INDEX_TAB          =
          ARCHIVE_PARAMETERS         = H_ARCHIVE_PARAMS
          CONTROL_PARAMETERS         = t_control_parameters
        MAIL_APPL_OBJ              =
        MAIL_RECIPIENT             =
        MAIL_SENDER                =
        OUTPUT_OPTIONS             =
        USER_SETTINGS              = 'X'
          Variable                   =  v_flag
        IMPORTING
        DOCUMENT_OUTPUT_INFO       =
          JOB_OUTPUT_INFO            = w_job_output_info
        JOB_OUTPUT_OPTIONS         =
        TABLES
          I_table                    = t_itab
        EXCEPTIONS
          FORMATTING_ERROR           = 1
          INTERNAL_ERROR             = 2
          SEND_ERROR                 = 3
          USER_CANCELED              = 4
          OTHERS                     = 5
    4. Convert the OTF format to PDF format using the w_job_output_info-otfdata
      DATA:  l_filesize TYPE i,
             t_lines LIKE tline OCCURS 0,
             t_objbin TYPE ty_tab_objbin.
    **/ Get the PDF version of the OTF
      CALL FUNCTION 'CONVERT_OTF'
        EXPORTING
          format                = 'PDF'
        IMPORTING
          bin_filesize          = l_filesize     
        bin_file              = bin_file
        TABLES
          otf                   = w_job_output_info-otfdata
          lines                 = t_lines
        EXCEPTIONS
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          OTHERS                = 4.
    5. Convert the PDF format to format required for attachment.
    **/ Convert the PDF format to the table type required for the attachment.
      CALL FUNCTION 'QCE1_CONVERT'
        TABLES
          t_source_tab         = t_lines     
          t_target_tab         = t_objbin
        EXCEPTIONS
          convert_not_possible = 1
          OTHERS               = 2.
    6. Create the document to be sent by e-mail
    Creation of the document to be sent
    File Name: Name of the file to be attached
      w_doc_chng-obj_name  = ‘Flename’.
    Mail Subject
      w_doc_chng-obj_descr = ‘Test E-mail’(em1).
    Completing the recipient list     
      t_reclist-receiver = t_rec.          “e-mail id of the recipient
      t_reclist-rec_type = 'U'.
      APPEND t_reclist.
    Mail Contents
      t_objtxt = 'Line 1'(bd1).
      APPEND t_objtxt.
      CLEAR t_objtxt.                               
      APPEND t_objtxt.                         " to put in a blank line
      t_objtxt = 'Line 2'(bd2).
      APPEND t_objtxt.
      CLEAR t_objtxt.                
      t_objtxt = ‘Line 3'(bd3).
      APPEND t_objtxt.
      CLEAR t_objtxt.                                      
      APPEND t_objtxt.                         " to put in a blank line
      t_objtxt = ‘Line 4’(bd3).
      APPEND t_objtxt.
    Calculate email size in bytes
      DESCRIBE TABLE t_objtxt LINES w_tab_lines.
      READ TABLE t_objtxt INDEX w_tab_lines.
      w_doc_chng-doc_size = ( w_tab_lines - 1 ) * 255 + STRLEN( t_objtxt ).
    Creation of the entry for the compressed document
    for the email text
      CLEAR t_objpack-transf_bin.
      t_objpack-head_start = 1.
      t_objpack-head_num   = 0.
      t_objpack-body_start = 1.
      t_objpack-body_num   = w_tab_lines.
      t_objpack-doc_type   = 'RAW'.
      APPEND t_objpack.
    Creation of the document attachment
    (Assume that the data in OBJBIN is in BMP format)
      DESCRIBE TABLE p_objbin LINES w_tab_lines.
      t_objhead = ‘Fielname.PDF'(em5).
      APPEND t_objhead.
      CLEAR t_objpack.
    **/ Creation of the entry for the compressed/attached document
      t_objpack-transf_bin = c_x.
      t_objpack-head_start = 1.
      t_objpack-head_num   = 1.
      t_objpack-body_start = 1.
      t_objpack-body_num   = w_tab_lines.
      t_objpack-doc_type   = 'PDF'.
      t_objpack-obj_name   = 'Possibly hover name'.
      t_objpack-obj_descr  = ‘Mail Description'(em6).
      t_objpack-doc_size   = w_tab_lines * 255.
      APPEND t_objpack.
    7. Send the document by e-mail
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = w_doc_chng
          put_in_outbox              = c_x
        TABLES
          packing_list               = t_objpack
          object_header              = t_objhead
          contents_bin               = t_objbin
          contents_txt               = t_objtxt
          receivers                  = t_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      IF sy-subrc <> 0.
        WRITE: / text-014, sy-subrc.
      ELSE.
        WRITE:  / text-015.
      ENDIF.
    8. Commit work: this step is important to send the email to transaction SOST.
    Once the email has reached the transaction SOST then it’s the job of the basis to do the configuration to send it to the specified e-mail id by internet.
    **commit work for the email to go into transaction SOST.
      COMMIT WORK.
    9.  In transaction SOST the mail will appear.

  • How to send smartform as email (smartform content in the email body)

    Hi,
    When I call my smartform, I want to send the smartform content as email. I am seeing one structure : MAIL_RECIPIENT.
    I have the mail id in my hand : xyz. However, based on this email id, how to populate the structure MAIL_RECIPIENT since it has Object ID, Object type and descrption. But No field for Email ID.
    Can any one help me out, in this.
    Thanks,
    Sandeep

    Hi,
    No not the PDF. The content it self should go as email.
    For that only we need to populate MAIL_RECIPIENT structure.
    But my doubt is how to populate this structure. It has no field for email ID.
    Thanks,
    Sandeep

  • 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

  • Email smartform in html format

    Hello all,
    I've been searching SDN for help with creating an email in html format via smartforms. Pavan Bayyapu's blog was really helpful and I've also used program SF_XSF_DEMO_MAIL as the basis for my program.  I followed their examples exactly but my emails always appear as a .MTL attachment, never as just the body of the email. 
    I tried removing the file name from lo_mime_helper->set_main_html and from lo_mime_helper->add_binary_part as suggested by some other folks but I haven't had any success.
    Has anyone solved this same issue?  Maximum points will be given to helpful suggestions. 
    Thank you.

    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/59/cd7da407d711d5b66f006094192fe3/content.htm">converting SF to html format</a>
    Here is the code to send the Smartform to mail as PDF attachment.
    *& Report ZTEST_PDF_MAIL
    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 = '[email protected]'.
    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.
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • Emailed Smartform Not Producing a Spool ID

    Hi,
    I'm trying to create a spool ID when I email my smartform.  The emailing works but when I call the smartform function module the table JOB_OUTPUT_INFO-SPOOLIDS isn't being populated.
    I'm passing the following parameters to my smartform:
    OUTPUT_OPTIONS-TDNOPREV = 'X'.
    OUTPUT_OPTIONS-TDNEWID = 'X'.
    OUTPUT_OPTIONS-TDIMMED = 'X'.
    CONTROL_PARAMETERS-NO_DIALOG = 'X'.
    CONTROL_PARAMETERS-GETOTF = 'X'.
    Can you tell me what I'm doing wrong?
    Thanks,
    Gill

    Hi Gill,
    I guess when calling the function module of the Smartform from your print program you set parameter  CONTROL_PARAMETERS-DEVICE = 'MAIL'. In this case the smartform is converted to a PDF mail attachment. usually a different setting is used in the application for printing so different parameters are used to call the smartforms function module.
    You could acticate the SAVE_OTF_SPOOL option via report RSTXPDF3 but this is only recomended for a short period for testing as per SAP note 924752.
    Regards,
    Aidan

  • Email Smartform in Future

    I would like to be able to email a Smartform on a future date from ABAP code.
    I have all the code working to call the Smartform and email it immediately.
    I need to know how to set the "Do Not Send Before Date" & "Do Not Send Before Time" fields that are shown in tx SOST.
    We are running a 4.7 system.
    Any ideas would be great.

    I would like to be able to email a Smartform on a future date from ABAP code.
    I have all the code working to call the Smartform and email it immediately.
    I need to know how to set the "Do Not Send Before Date" & "Do Not Send Before Time" fields that are shown in tx SOST.
    We are running a 4.7 system.
    Any ideas would be great.

  • How to email Smartforms

    I am trying to e-mail a smartform and I think I might have most of it figured out.  The part I am confused about is the mail_appl_object and what exactly is required.  I have copied my code below and I am getting the error "The type swc_object is unknown".  I basically copied most of this code from other users on the SDN.   Can someone please help .... what exactly would I need to do?  thx!
    control_parameters TYPE ssfctrlop.  
    control_parameters-device = 'MAIL'.
    DATA:     email_recipient     TYPE SWOTOBJID,    
              email_sender        TYPE SWOTOBJID,    
              g_mail_app_obj type SWOTOBJID,
         FOLDER TYPE swcobject,           
         BEGIN OF SOFMFOL_KEY,
         FOLDERTYPE LIKE SOFM-FOLTP,
         FOLDERYEAR LIKE SOFM-FOLYR,
         FOLDERNUMBER LIKE SOFM-FOLNO,
         TYPE LIKE SOFM-DOCTP,
         YEAR LIKE SOFM-DOCYR,
         NUMBER LIKE SOFM-DOCNO,
         FORWARDER LIKE SOUB-USRNAM,
         END OF SOFMFOL_KEY,
         BOR_KEY LIKE SWOTOBJID-OBJKEY.
    PERFORM mail_recipient_object.
    PERFORM mail_sender_object.
    PERFORM mail_appl_object.
    *Determine Function Module Name of SmartForm
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          FORMNAME = 'ZMY_SMARTFORM'        "SmartForm Name
        IMPORTING
          FM_NAME  = func_mod_name            EXCEPTIONS
         OTHERS   = 1.
    CALL FUNCTION func_mod_name
    EXPORTING
       CONTROL_PARAMETERS         =  control_parameters
       MAIL_APPL_OBJ              =  g_mail_app_obj
       MAIL_RECIPIENT             =  email_recipient
       MAIL_SENDER                =  email_sender
       USER_SETTINGS              = 'X'
       MTRL_NO                    = icoa_dlvrys-matnr
       MTRL_DESCR                 = icoa_dlvrys-maktx
       CUSTOMER_NO                = icoa_dlvrys-kunnr
       CUSTOMER_NAME              = icoa_dlvrys-name1
       V_MANDT                    = sy-mandt
       V_SYSID                    = sy-sysid
       CERTIFIED_BY               = r_certby
    TABLES
        izqm_coa_prpylene          = izqm_coa_prpylene
    EXCEPTIONS
       FORMATTING_ERROR           = 1
       INTERNAL_ERROR             = 2
       SEND_ERROR                 = 3
       USER_CANCELED              = 4
       OTHERS                     = 5.
    **FORM:  mail_recipient_object
    FORM mail_recipient_object.
    data: email_address TYPE SO_NAME.
    email_address =  '[email protected]'.
    CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
    EXPORTING
       IP_MAILADDR             = email_address        
       IP_TYPE_ID              =  'U'             
    IMPORTING
       EP_RECIPIENT_ID         = email_recipient
    EXCEPTIONS
       INVALID_RECIPIENT       = 1
       OTHERS                  = 2.
    ENDFORM.    "mail_recipient_object.
    *----*FORM:  mail_sender_object
    FORM mail_sender_object.
    CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
    EXPORTING
       IP_SENDER            = sy-uname
    IMPORTING
       EP_SENDER_ID         = email_sender
    EXCEPTIONS
       INVALID_SENDER       = 1
       OTHERS               = 2.
    ENDFORM.    "mail_sender_object.
    *----* FORM mail_appl_object.
    FORM mail_appl_object.
    SELECT * from soud INTO soud
      WHERE sapnam LIKE sy-uname and deleted = ''.
    endselect.
    IF sy-subrc <> 0.
    CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'
    EXPORTING
       SAPNAME                       = SY-UNAME
    EXCEPTIONS
       NO_INSERT                     = 1
       SAP_NAME_EXIST                = 2
       X_ERROR                       = 3
       SAP_NAME_NOT_EXIST            = 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.
      CLEAR soud.
    ELSE.
    ENDIF.
    ENDIF.
    CLEAR sofmfol_key.
    sofmfol_key-type = 'FOL'.
    sofmfol_key-year = soud-inbyr.
    sofmfol_key-number = soud-inbno.
    bor_key = sofmfol_key.
    IF NOT bor_key IS INITIAL.
    swc_create_object folder 'SOFMFOL' bor_key.
    IF sy-subrc = 0.
      swc_object_to_persistent folder p_mail_app_obj.
      IF sy-subrc NE 0.
        CLEAR g_mail_app_obj.
      ENDIF.
    ENDIF.
    ELSE.
      CLEAR g_mail_app_obj.
    ENDIF.
    ENDFORM.  "mail_appl_object.

    Hello SAP gurus,
    I am trying to send a sample smartform by email by using the code below. When I execute the program system shows below succes message.
    "MAIL request 000000000029 created successfully.
    Message no. SSFCOMPOSER024"
    But I can see nothing coming in SCOT/SOST and it doesnt sends any email.
    Is there anything I need to configure in system settings.
    Moreover when I try to send any email to extenal email addresses from SAP office system is sending email correctly.
    Any help would be highly appreciated.
    Thanks in advance,
    Shabbeer.
    *& Report  Z_SF_EX_03                                                  *
    REPORT  Z_SF_EX_03                              .
    tables: soud.
    data: carr_id type sbook-carrid,
          fm_name type rs38l_fnam.
         cust_id type scustom-id.
    parameter: p_custid type scustom-id default 1.
    select-options: "s_custid for cust_id default 1 to 1,
                    s_carrid for carr_id     default 'LH' to 'LH'.
    parameter:      p_form   type tdsfname   default 'SF_EXAMPLE_01'.
                   p_email  type
    data: customer    type scustom,
          bookings    type ty_bookings,
          connections type ty_connections,
          output_option type ssfcompop,
          zssfcrescl type ssfcrescl,
          zssfcresop type ssfcresop.
    include <cntn01>.
    get data
    select single * from scustom
      into customer
      where id eq p_custid.
    check sy-subrc = 0.
    select * from sbook into table bookings
             where customid eq p_custid
             and   carrid   in s_carrid
             order by primary key.
    select * from spfli into table connections
             for all entries in bookings
             where carrid = bookings-carrid
             and   connid = bookings-connid
             order by primary key.
    data: control_parameters TYPE ssfctrlop,
    output_options TYPE ssfcompop,
    EMail_Subject(50) TYPE c.
    DATA: email_recipient TYPE SWOTOBJID,
    email_sender TYPE SWOTOBJID,
    g_mail_app_obj type SWOTOBJID.
    concatenate text-004 '400000124' into EMail_Subject.
    control_parameters-device = 'MAIL'.
    control_parameters-no_dialog = 'X'.
    control_parameters-preview = 'X'."space.
    output_options-tdnewid = 'X'.
    output_options-tdtitle = EMail_Subject.
    PERFORM mail_recipient_object.
    PERFORM mail_sender_object.
    PERFORM mail_appl_object changing g_mail_app_obj.
    *Determine Function Module Name of SmartForm
    call function 'SSF_FUNCTION_MODULE_NAME'
         exporting  formname           = p_form
                    variant            = ' '
                    direct_call        = ' '
         importing  fm_name            = fm_name
         exceptions no_form            = 1
                    no_function_module = 2
                    others             = 3.
    if sy-subrc <> 0.
      error handling
      message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      exit.
    endif.
    now call the generated function module
        call function fm_name
             exporting
                    archive_index        =
                    archive_parameters   =
                       control_parameters   = control_parameters
                         mail_appl_obj        = g_mail_app_obj
                         mail_recipient       = email_recipient
                         mail_sender          = email_sender
                         output_options       = output_options
                         user_settings        = 'X'
                        customer             = customer
                        bookings             = bookings
                        connections          = connections
          importing
         document_output_info =
                     job_output_info      = zssfcrescl
                     job_output_options   = zssfcresop
             exceptions formatting_error     = 1
                        internal_error       = 2
                        send_error           = 3
                        user_canceled        = 4
                        others               = 5.
    *break-point.
    **FORM: mail_recipient_object
    FORM mail_recipient_object.
    data: email_address TYPE SO_NAME.
    email_address = '[email protected]'.
    CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
    EXPORTING
    IP_MAILADDR = email_address
    IP_TYPE_ID = 'U'
    IMPORTING
    EP_RECIPIENT_ID = email_recipient
    EXCEPTIONS
    INVALID_RECIPIENT = 1
    OTHERS = 2
    ENDFORM. "mail_recipient_object.
    *----*FORM:
    *form mail_sender_object
    FORM
    form mail_sender_object.
    CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
    EXPORTING
    IP_SENDER = sy-uname
    IMPORTING
    EP_SENDER_ID = email_sender
    EXCEPTIONS
    INVALID_SENDER = 1
    OTHERS = 2.
    ENDFORM. "mail_sender_object.
    *----* FORM
    *form mail_appl_object.
    FORM
    form mail_appl_object changing g_mail_app_obj.
    DATA: FOLDER TYPE swc_object,
    BEGIN OF SOFMFOL_KEY,
    FOLDERTYPE LIKE SOFM-FOLTP,
    FOLDERYEAR LIKE SOFM-FOLYR,
    FOLDERNUMBER LIKE SOFM-FOLNO,
    TYPE LIKE SOFM-DOCTP,
    YEAR LIKE SOFM-DOCYR,
    NUMBER LIKE SOFM-DOCNO,
    FORWARDER LIKE SOUB-USRNAM,
    END OF SOFMFOL_KEY,
    BOR_KEY LIKE SWOTOBJID-OBJKEY.
    SELECT single * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
    IF sy-subrc NE 0.
    CALL FUNCTION 'SO_USER_AUTOMATIC_INSERT'
    EXPORTING
    SAPNAME = SY-UNAME
    EXCEPTIONS
    NO_INSERT = 1
    SAP_NAME_EXIST = 2
    X_ERROR = 3
    SAP_NAME_NOT_EXIST = 4
    OTHERS = 5.
    ENDIF.
    clear sofmfol_key.
    sofmfol_key-type = 'FOL'.
    sofmfol_key-year = soud-inbyr.
    sofmfol_key-number = soud-inbno.
    bor_key = sofmfol_key.
    IF not bor_key is initial.
    swc_create_object folder 'SOFMFOL' bor_key.
    IF sy-subrc = 0.
    swc_object_to_persistent folder g_mail_app_obj.
    IF sy-subrc ne 0.
    clear g_mail_app_obj.
    ENDIF.
    ENDIF.
    ELSE.
    clear g_mail_app_obj.
    ENDIF.
    ENDFORM. "mail_appl_object.

  • Emailing smartform with datamatrix 2d barcode

    We have a demand to put datamatrix 2d barcode on our delivery forms (manifest and bill of lading).  These forms are smarforms.
    When printed the datamatrix 2d barcode on the smartforms is what it should be.  Our problem is when we want to email these forms the datamatrix 2d barcode is represented by 4 vertical lines.  What I understand is that the datamatrix 2d barcode is generated by the print driver and when emailing it does not pass by the printer.  
    How can theses forms be sent by email with the datamatrix 2d barcode.
    Thank you for your help.

    How do you email the form?
    Since the printout works OK, I'd think if you call the Smartform's function module with the proper device (printer) specified and request the OTF data, you should be able to convert that OTF to PDF, attach it to an email and send it to the desired recipient(s).
    At least that's the path I'd try to follow...

  • Smartforms - Email

    Hi Experts,
    Plz tell me how to send (email) the output of a purchase order when i save it in ME21n or me22n like ALE.

    hi
    chk this
    Re: How to email Smartforms
    hope this helps
    regards
    Aakash Banga

  • Link from IS-U connection object to email from marketing campain

    Hi all,
    I've a problem with emails from marketing campains in WebUI.
    If you send an email from such a campain, it is linked at the contact historie of the receiving BP.
    But we need an additional link from the IS-U connection objects of this BP to this email.
    I implemented the badi CRM_MKT_MODIFY_ORDER to add the link in the docflow segment.
    but now there a two mistakes. from the contact history of the BP the link still starts BT126H_MAIL, but only the part "references" is filled with BP, contact, res.employee and header data of the marketing campain. The email block is empty although the mail was sent correctly. Why am I losing the reference to the the email/smartform?
    the second mistake is even more curious to me. in the contact history of the connection object is a link to the email created. But the link leads to component BT126H_APPT although its category is email.
    Any idea, what's my mistake?
    regards
    Martin
    Edited by: Martin Knittel on Aug 3, 2009 5:11 PM:
    I solved problem no 1. Forgot a partner dataset in the badi.
    But need still your help with problem no 2. Why is there a link to BT126H_APPT instead of BT126H_MAIL?

    Was a mistake in standard coding. Solved by sap note

  • Attach document from documents tab to a Smartform

    Guru's,
    We want to send an Email (Smartform), via an action in the Order,  and to this email we want to attach a document which is assigned to the Order (in the documents tab).
    Does anyone knwo if this is possibel. And if any coding is required, please provide me with this code?
    Will reward points!
    Thanks in advance.
    Regards,
    Joost

    Hi,
    I have a similar requirement,Can u pls tell wht coding is required.
    Thanks
    Akshatha

  • HTML Mail Smartform

    Hi,
    Was wondering if someone please can advise if it is possible to send HTML email Smartforms. I checked SCOT and it seems that you can only choose plain text or PDF attachment?
    Thanks,
    Sebastiaan.

    Have you checked out transaction CRMD_EMAIL
    This is where we build our HTML for email campaigns

  • Smartforms output as HTML in email

    Hi,
    I want to send the output of a smartform as html in email body.
    I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
    I did everything as per the blog.
    However I am getting the email as:
    sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    When I display the document using SOST, I get the output as
    Address bar has this:  C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
    and window contains:
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
    Regards,
    Reema
    Message was edited by:
            Reema Shahbazkar
    In case anyone needs to have a look at my code:
    REPORT  ZSMARTFORM_2_HTML_EMAIL.
    get generated function module for the smartform
    DATA: FM_NAME TYPE RS38L_FNAM.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZSF_SAMPLE_HTML'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       FM_NAME                  = FM_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.
    get smartform contetnt
    set smartform output options
    data:
      control_parameters type SSFCTRLOP,
      OUTPUT_OPTIONS     TYPE SSFCOMPOP,
      DOCUMENT_OUTPUT_INFO  TYPE SSFCRESPD,
      JOB_OUTPUT_INFO  TYPE SSFCRESCL,
      JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
      XSFPARAM_LINE TYPE SSFXSFP,
      P_HTML TYPE TRFRESULT,
      P_GRAPHICS TYPE TSF_XSF_GR,
      WA_RETURN TYPE BAPIRET2.
    CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
    control_parameters-NO_DIALOG = 'X'.
    *control_parameters-GETOTF = 'X'.
    OUTPUT_OPTIONS-TDNEWID = SPACE.
    OUTPUT_OPTIONS-TDIMMED = SPACE.
    OUTPUT_OPTIONS-XSFCMODE = 'X'.  "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
    OUTPUT_OPTIONS-XSF = 'X'.  "XSF OUTPUT ACTIVATED
    OUTPUT_OPTIONS-XSFOUTMODE = 'A'.  "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
    CLEAR: OUTPUT_OPTIONS-XSFOUTDEV.  "OUTPUT SPOOL DEVICE
    OUTPUT_OPTIONS-XSFFORMAT = 'X'.  "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
    XSFPARAM_LINE-NAME = 'GRAPHICS'.
    XSFPARAM_LINE-VALUE = 'EXTRACT'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
    XSFPARAM_LINE-VALUE = C_GR_DIR.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'CONTENT-ID'.
    XSFPARAM_LINE-VALUE = 'ENABLE'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
    CALL FUNCTION FM_NAME
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = CONTROL_PARAMETERS
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = OUTPUT_OPTIONS
      USER_SETTINGS              = 'X'
    IMPORTING
       DOCUMENT_OUTPUT_INFO       = DOCUMENT_OUTPUT_INFO
       JOB_OUTPUT_INFO            = JOB_OUTPUT_INFO
       JOB_OUTPUT_OPTIONS         = JOB_OUTPUT_OPTIONS
    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.
    SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
    P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
    P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
    PROCEED TO SEND EMAIL
    DATA: HTML_DATA TYPE TRFRESULT,
          L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
          HTML_XSTR TYPE XSTRING.
    CLEAR: HTML_XSTR.
    LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
      CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
    ENDLOOP.
    HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
    SPECIAL CHARACTER CONVERSION
    DATA: HTML_STR TYPE STRING,
          HTML_LEN TYPE I.
    CALL FUNCTION 'SCP_TRANSLATE_CHARS'
      EXPORTING
        INBUFF                   = HTML_XSTR
      INBUFFLG                 = 0
       INCODE                   = '4110'  "utf-8
      OUTBUFFLG                = 0
      OUTCODE                  = '0000'
       CSUBST                   = 'X'
      SUBSTC_HASH              = ' '
      SUBSTC_DOT               = ' '
       SUBSTC_SPACE             = 'x'
      SUBSTC                   = '00035'
    IMPORTING
      INUSED                   =
       OUTBUFF                  = HTML_STR
      OUTOVERFLOW              =
       OUTUSED                  = HTML_LEN
      SUBSTED                  =
      INPUT_ENDS_IN_CHAR       =
      ERRMSG                   =
    EXCEPTIONS
      INVALID_CODEPAGE         = 1
      INTERNAL_ERROR           = 2
      CANNOT_CONVERT           = 3
      FIELDS_BAD_TYPE          = 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.
    CHANGE ENCODING UTF-8 TO LATIN1
    REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
    HTML_LEN = STRLEN( HTML_STR ).
    DATA: L_OFFSET TYPE I,
          L_LENGTH TYPE I,
          L_DIFF TYPE I,
          LT_SOLI TYPE SOLI_TAB,
          LS_SOLI TYPE SOLI.
    L_OFFSET = 0.
    L_LENGTH = 255.
    WHILE L_OFFSET < HTML_LEN.
      L_DIFF = HTML_LEN - L_OFFSET.
      IF L_DIFF > L_LENGTH.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
      ELSE.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
      ENDIF.
      APPEND LS_SOLI TO LT_SOLI.
      ADD L_LENGTH TO L_OFFSET.
    ENDWHILE.
    DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
    CREATE OBJECT LO_MIME_HELPER
      EXPORTING
        CODEPAGE = '1133'.
    CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
      EXPORTING
        CONTENT     = LT_SOLI
       FILENAME    =
       DESCRIPTION =
    HANDLE GRAPHICS
    DATA: L_GRAPHIC TYPE SSF_XSF_GR,
          GR_XSTR TYPE XSTRING,
          L_GR_RAW TYPE BAPICONTEN,
          L_CONTENT_ID TYPE STRING,
          L_CONTENT_TYPE TYPE W3CONTTYPE,
          L_OBJ_LEN TYPE SO_OBJ_LEN,
          L_FILENAME TYPE STRING,
          LT_SOLIX TYPE SOLIX_TAB,
          LS_SOLIX TYPE SOLIX.
    LOOP AT P_GRAPHICS INTO L_GRAPHIC.
      CLEAR: GR_XSTR.
      LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
        CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
      ENDLOOP.
      GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
      L_OFFSET = 0.
      L_LENGTH = 255.
      CLEAR LT_SOLIX[].
      WHILE L_OFFSET < L_GRAPHIC-LENGTH.
        L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
        IF L_DIFF > L_LENGTH.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
        ELSE.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
        ENDIF.
        APPEND LS_SOLIX TO LT_SOLIX.
        ADD L_LENGTH TO L_OFFSET.
      ENDWHILE.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
      L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
      L_OBJ_LEN = L_GRAPHIC-LENGTH.
    ADD IMAGES TO EMAIL
      CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
        EXPORTING
          CONTENT      = LT_SOLIX
         FILENAME     =
         EXTENSION    =
         DESCRIPTION  =
          CONTENT_TYPE = L_CONTENT_TYPE
          LENGTH       = L_OBJ_LEN
          CONTENT_ID   = L_CONTENT_ID
    ENDLOOP.
    DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
          P_SUBJECT TYPE SO_OBJ_DES,
          LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
          LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
          LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
      P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
      TRY.
      CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
        EXPORTING
          I_SUBJECT          = P_SUBJECT
          I_LANGUAGE         = SY-LANGU
          I_IMPORTANCE       = '5'
          I_SENSITIVITY      = 'F'
          I_MULTIREL_SERVICE = LO_MIME_HELPER
        RECEIVING
          RESULT             = LO_DOC_BCS
       CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
       CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
       CATCH CX_GBT_MIME INTO LV_GBT_MIME.
      ENDTRY.
    RECEIVERS
    DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
          RECEIVER TYPE SOMLRECI1,
          L_MAIL_ADDRESS TYPE AD_SMTPADR,
          LO_BCS TYPE REF TO CL_BCS,
          LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
          L_USERNAME TYPE UNAME,
          SEND_PARTNER TYPE BU_PARTNER,
          LI_SENDER TYPE REF TO IF_SENDER_BCS,
          LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
          LV_SENT_TO_ALL TYPE BOOLEAN.
    CLEAR RECEIVER.
    RECEIVER-RECEIVER = '[email protected]'.
    RECEIVER-REC_TYPE = 'U'.
    RECEIVER-COM_TYPE = 'INT'.
    APPEND RECEIVER TO P_RECEIVERS.
    L_USERNAME = SY-UNAME.
    CLEAR RECEIVER.
    LOOP AT P_RECEIVERS INTO RECEIVER.
      L_MAIL_ADDRESS = RECEIVER-RECEIVER.
      TRY.
      CALL METHOD CL_BCS=>CREATE_PERSISTENT
        RECEIVING
          RESULT = LO_BCS
       CALL METHOD LO_BCS->SET_DOCUMENT
         EXPORTING
           I_DOCUMENT = LO_DOC_BCS
       CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
      ENDTRY.
    CREATE SENDER
    CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
    TRY.
      IF L_USERNAME NS '@'.
        L_USERNAME = SEND_PARTNER.
        TRANSLATE L_USERNAME TO UPPER CASE.
        LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
      ELSE.
        DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
        L_FROM_MAIL_ADDRESS = L_USERNAME.
        LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
      ENDIF.
      CALL METHOD LO_BCS->SET_SENDER
        EXPORTING
          I_SENDER = LI_SENDER
    CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    create recepient
    data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
    TRY.
    CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
       EXPORTING
         I_ADDRESS_STRING = L_MAIL_ADDRESS
        I_ADDRESS_NAME   =
        I_INCL_SAPUSER   =
       RECEIVING
         RESULT           = LO_RECEPIENT
      CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    ENDTRY.
    TRY.
    CALL METHOD LO_BCS->ADD_RECIPIENT
       EXPORTING
         I_RECIPIENT  = LO_RECEPIENT
        I_EXPRESS    =
        I_COPY       =
        I_BLIND_COPY =
        I_NO_FORWARD =
      CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    SEND EMAIL DOCUMENT
    TRY.
    CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
      EXPORTING
        I_REQUESTED_STATUS = 'N'
    TRY.
    CALL METHOD LO_BCS->SEND
    EXPORTING
       I_WITH_ERROR_SCREEN = SPACE
      RECEIVING
        RESULT              = LV_SENT_TO_ALL
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    ENDTRY.
    ENDLOOP.
    COMMIT WORK.

    Hi,
    I want to send the output of a smartform as html in email body.
    I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
    I did everything as per the blog.
    However I am getting the email as:
    sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
    When I display the document using SOST, I get the output as
    Address bar has this:  C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
    and window contains:
    Welcome
    <IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
    Regards,
    Reema
    Message was edited by:
            Reema Shahbazkar
    In case anyone needs to have a look at my code:
    REPORT  ZSMARTFORM_2_HTML_EMAIL.
    get generated function module for the smartform
    DATA: FM_NAME TYPE RS38L_FNAM.
    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
      EXPORTING
        FORMNAME                 = 'ZSF_SAMPLE_HTML'
      VARIANT                  = ' '
      DIRECT_CALL              = ' '
    IMPORTING
       FM_NAME                  = FM_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.
    get smartform contetnt
    set smartform output options
    data:
      control_parameters type SSFCTRLOP,
      OUTPUT_OPTIONS     TYPE SSFCOMPOP,
      DOCUMENT_OUTPUT_INFO  TYPE SSFCRESPD,
      JOB_OUTPUT_INFO  TYPE SSFCRESCL,
      JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
      XSFPARAM_LINE TYPE SSFXSFP,
      P_HTML TYPE TRFRESULT,
      P_GRAPHICS TYPE TSF_XSF_GR,
      WA_RETURN TYPE BAPIRET2.
    CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
    control_parameters-NO_DIALOG = 'X'.
    *control_parameters-GETOTF = 'X'.
    OUTPUT_OPTIONS-TDNEWID = SPACE.
    OUTPUT_OPTIONS-TDIMMED = SPACE.
    OUTPUT_OPTIONS-XSFCMODE = 'X'.  "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
    OUTPUT_OPTIONS-XSF = 'X'.  "XSF OUTPUT ACTIVATED
    OUTPUT_OPTIONS-XSFOUTMODE = 'A'.  "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
    CLEAR: OUTPUT_OPTIONS-XSFOUTDEV.  "OUTPUT SPOOL DEVICE
    OUTPUT_OPTIONS-XSFFORMAT = 'X'.  "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
    XSFPARAM_LINE-NAME = 'GRAPHICS'.
    XSFPARAM_LINE-VALUE = 'EXTRACT'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
    XSFPARAM_LINE-VALUE = C_GR_DIR.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    XSFPARAM_LINE-NAME = 'CONTENT-ID'.
    XSFPARAM_LINE-VALUE = 'ENABLE'.
    APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
    CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
    CALL FUNCTION FM_NAME
    EXPORTING
      ARCHIVE_INDEX              =
      ARCHIVE_INDEX_TAB          =
      ARCHIVE_PARAMETERS         =
       CONTROL_PARAMETERS         = CONTROL_PARAMETERS
      MAIL_APPL_OBJ              =
      MAIL_RECIPIENT             =
      MAIL_SENDER                =
       OUTPUT_OPTIONS             = OUTPUT_OPTIONS
      USER_SETTINGS              = 'X'
    IMPORTING
       DOCUMENT_OUTPUT_INFO       = DOCUMENT_OUTPUT_INFO
       JOB_OUTPUT_INFO            = JOB_OUTPUT_INFO
       JOB_OUTPUT_OPTIONS         = JOB_OUTPUT_OPTIONS
    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.
    SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
    P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
    P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
    PROCEED TO SEND EMAIL
    DATA: HTML_DATA TYPE TRFRESULT,
          L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
          HTML_XSTR TYPE XSTRING.
    CLEAR: HTML_XSTR.
    LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
      CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
    ENDLOOP.
    HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
    SPECIAL CHARACTER CONVERSION
    DATA: HTML_STR TYPE STRING,
          HTML_LEN TYPE I.
    CALL FUNCTION 'SCP_TRANSLATE_CHARS'
      EXPORTING
        INBUFF                   = HTML_XSTR
      INBUFFLG                 = 0
       INCODE                   = '4110'  "utf-8
      OUTBUFFLG                = 0
      OUTCODE                  = '0000'
       CSUBST                   = 'X'
      SUBSTC_HASH              = ' '
      SUBSTC_DOT               = ' '
       SUBSTC_SPACE             = 'x'
      SUBSTC                   = '00035'
    IMPORTING
      INUSED                   =
       OUTBUFF                  = HTML_STR
      OUTOVERFLOW              =
       OUTUSED                  = HTML_LEN
      SUBSTED                  =
      INPUT_ENDS_IN_CHAR       =
      ERRMSG                   =
    EXCEPTIONS
      INVALID_CODEPAGE         = 1
      INTERNAL_ERROR           = 2
      CANNOT_CONVERT           = 3
      FIELDS_BAD_TYPE          = 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.
    CHANGE ENCODING UTF-8 TO LATIN1
    REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
    REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
    HTML_LEN = STRLEN( HTML_STR ).
    DATA: L_OFFSET TYPE I,
          L_LENGTH TYPE I,
          L_DIFF TYPE I,
          LT_SOLI TYPE SOLI_TAB,
          LS_SOLI TYPE SOLI.
    L_OFFSET = 0.
    L_LENGTH = 255.
    WHILE L_OFFSET < HTML_LEN.
      L_DIFF = HTML_LEN - L_OFFSET.
      IF L_DIFF > L_LENGTH.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
      ELSE.
        LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
      ENDIF.
      APPEND LS_SOLI TO LT_SOLI.
      ADD L_LENGTH TO L_OFFSET.
    ENDWHILE.
    DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
    CREATE OBJECT LO_MIME_HELPER
      EXPORTING
        CODEPAGE = '1133'.
    CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
      EXPORTING
        CONTENT     = LT_SOLI
       FILENAME    =
       DESCRIPTION =
    HANDLE GRAPHICS
    DATA: L_GRAPHIC TYPE SSF_XSF_GR,
          GR_XSTR TYPE XSTRING,
          L_GR_RAW TYPE BAPICONTEN,
          L_CONTENT_ID TYPE STRING,
          L_CONTENT_TYPE TYPE W3CONTTYPE,
          L_OBJ_LEN TYPE SO_OBJ_LEN,
          L_FILENAME TYPE STRING,
          LT_SOLIX TYPE SOLIX_TAB,
          LS_SOLIX TYPE SOLIX.
    LOOP AT P_GRAPHICS INTO L_GRAPHIC.
      CLEAR: GR_XSTR.
      LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
        CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
      ENDLOOP.
      GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
      L_OFFSET = 0.
      L_LENGTH = 255.
      CLEAR LT_SOLIX[].
      WHILE L_OFFSET < L_GRAPHIC-LENGTH.
        L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
        IF L_DIFF > L_LENGTH.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
        ELSE.
          LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
        ENDIF.
        APPEND LS_SOLIX TO LT_SOLIX.
        ADD L_LENGTH TO L_OFFSET.
      ENDWHILE.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
      CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
      L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
      L_OBJ_LEN = L_GRAPHIC-LENGTH.
    ADD IMAGES TO EMAIL
      CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
        EXPORTING
          CONTENT      = LT_SOLIX
         FILENAME     =
         EXTENSION    =
         DESCRIPTION  =
          CONTENT_TYPE = L_CONTENT_TYPE
          LENGTH       = L_OBJ_LEN
          CONTENT_ID   = L_CONTENT_ID
    ENDLOOP.
    DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
          P_SUBJECT TYPE SO_OBJ_DES,
          LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
          LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
          LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
      P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
      TRY.
      CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
        EXPORTING
          I_SUBJECT          = P_SUBJECT
          I_LANGUAGE         = SY-LANGU
          I_IMPORTANCE       = '5'
          I_SENSITIVITY      = 'F'
          I_MULTIREL_SERVICE = LO_MIME_HELPER
        RECEIVING
          RESULT             = LO_DOC_BCS
       CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
       CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
       CATCH CX_GBT_MIME INTO LV_GBT_MIME.
      ENDTRY.
    RECEIVERS
    DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
          RECEIVER TYPE SOMLRECI1,
          L_MAIL_ADDRESS TYPE AD_SMTPADR,
          LO_BCS TYPE REF TO CL_BCS,
          LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
          L_USERNAME TYPE UNAME,
          SEND_PARTNER TYPE BU_PARTNER,
          LI_SENDER TYPE REF TO IF_SENDER_BCS,
          LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
          LV_SENT_TO_ALL TYPE BOOLEAN.
    CLEAR RECEIVER.
    RECEIVER-RECEIVER = '[email protected]'.
    RECEIVER-REC_TYPE = 'U'.
    RECEIVER-COM_TYPE = 'INT'.
    APPEND RECEIVER TO P_RECEIVERS.
    L_USERNAME = SY-UNAME.
    CLEAR RECEIVER.
    LOOP AT P_RECEIVERS INTO RECEIVER.
      L_MAIL_ADDRESS = RECEIVER-RECEIVER.
      TRY.
      CALL METHOD CL_BCS=>CREATE_PERSISTENT
        RECEIVING
          RESULT = LO_BCS
       CALL METHOD LO_BCS->SET_DOCUMENT
         EXPORTING
           I_DOCUMENT = LO_DOC_BCS
       CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
      ENDTRY.
    CREATE SENDER
    CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
    TRY.
      IF L_USERNAME NS '@'.
        L_USERNAME = SEND_PARTNER.
        TRANSLATE L_USERNAME TO UPPER CASE.
        LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
      ELSE.
        DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
        L_FROM_MAIL_ADDRESS = L_USERNAME.
        LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
      ENDIF.
      CALL METHOD LO_BCS->SET_SENDER
        EXPORTING
          I_SENDER = LI_SENDER
    CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    create recepient
    data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
    TRY.
    CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
       EXPORTING
         I_ADDRESS_STRING = L_MAIL_ADDRESS
        I_ADDRESS_NAME   =
        I_INCL_SAPUSER   =
       RECEIVING
         RESULT           = LO_RECEPIENT
      CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
    ENDTRY.
    TRY.
    CALL METHOD LO_BCS->ADD_RECIPIENT
       EXPORTING
         I_RECIPIENT  = LO_RECEPIENT
        I_EXPRESS    =
        I_COPY       =
        I_BLIND_COPY =
        I_NO_FORWARD =
      CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    SEND EMAIL DOCUMENT
    TRY.
    CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
      EXPORTING
        I_REQUESTED_STATUS = 'N'
    TRY.
    CALL METHOD LO_BCS->SEND
    EXPORTING
       I_WITH_ERROR_SCREEN = SPACE
      RECEIVING
        RESULT              = LV_SENT_TO_ALL
    CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
    ENDTRY.
    ENDTRY.
    ENDLOOP.
    COMMIT WORK.

  • Error while trying to open an attachment  sent through email in smartform

    Hi,
    My requirement is to send the smartform through email as PDF attachment.I am able to send the mail.But when I try to open the attachment I am getting error as 'Adobe reader could not open the attachment 'advance shipment notification.PDF' because it is either not the supported file type or the file has been corrupted(for example, it was sent as an email attachment and was't correctly decoded)'.What does it mean?
    Can anyone give me a proper solution for this?
    It's very urgent.Useful answers will be rewarded.
    Thanks,
    Hema

    Hi,
    Are you using any webdispatcher or some proxy? Is there any URL filter configured in between?
    If yes then I think you have to allow these pages.
    Regards,
    Vamshi.

Maybe you are looking for