cancel
Showing results for 
Search instead for 
Did you mean: 

Emailing smartforms

Former Member
0 Kudos

I am using the below code to send a smartform via an email. But I want to set the document text and insert text into the email - is there away to do this using the new'er object code. Or am I best using the ITF fucntionality?

* Get BOR-Objects for Recipient, Sender und Applikation
    PERFORM mail_recipient_object USING ls_recipient
                                  CHANGING g_mail_rec_obj.
    PERFORM mail_sender_object    CHANGING g_mail_sen_obj.
    PERFORM mail_appl_object      CHANGING g_mail_app_obj.

* Calling Smartform
    CALL FUNCTION lf_fm_name
      EXPORTING
        mail_recipient     = g_mail_rec_obj
        mail_sender        = g_mail_sen_obj
        control_parameters = g_cont_par
        mail_appl_obj      = g_mail_app_obj
        output_options     = g_output
        user_settings      = ' '
        hdr                = lv_hdr
      TABLES
        it_bsid            = lit_bsid
      EXCEPTIONS
        formatting_error   = 1
        internal_error     = 2
        send_error         = 3
        user_canceled      = 4
        others             = 5.

FORM MAIL_RECIPIENT_OBJECT  USING p_email
                            CHANGING P_MAIL_REC_OBJ.

  DATA: l_rectype   TYPE SO_ESCAPE VALUE 'U',
        l_email     TYPE SO_NAME.

        l_email = p_email.

  CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
   EXPORTING
*   IP_COUNTRY              =
*   IP_FAXNO                =
      ip_mailaddr             = l_email "g_mail type
                                       "SO_NAME.
      ip_type_id              = l_rectype " 'U'
    IMPORTING
      ep_recipient_id         = p_mail_rec_obj
*   EP_ADDRESS              =
*   ET_RECIPIENT            =
   EXCEPTIONS
     invalid_recipient       = 1
     OTHERS                  = 2
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.


ENDFORM.                    " MAIL_RECIPIENT_OBJECT
FORM MAIL_SENDER_OBJECT  CHANGING P_MAIL_SEN_OBJ.

  CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
    EXPORTING
      ip_sender      = sy-uname
    IMPORTING
      ep_sender_id   = p_mail_sen_obj
    EXCEPTIONS
      invalid_sender = 1
      OTHERS         = 2.
  IF sy-subrc  <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDFORM.                    " MAIL_SENDER_OBJECT
FORM MAIL_APPL_OBJECT  CHANGING P_MAIL_APP_OBJ.

  TABLES: soud.

  SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
  ENDSELECT.
  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
        OTHERS         = 4.
    IF sy-subrc NE 0.
      CLEAR soud.
    ELSE.
      SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
      ENDSELECT.
    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 p_mail_app_obj.
      ENDIF.
    ENDIF.
  ELSE.
    CLEAR p_mail_app_obj.
  ENDIF.


ENDFORM.                    " MAIL_APPL_OBJECT

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Refer --> [Email_smartforms|;

Hope this helps.

--Dep

Answers (0)