Skip to Content
0
Former Member
Jun 03, 2009 at 12:26 PM

Problem in sending email with the smartform output as PDF attachment.

435 Views

Hi,

I have written a code to send a email with the smartform output as attachment. But the problem is, though the code runs successfully (all sy-subrc checks are 0), still the email is not being sent to the recipient.

I am posting the code below :

"Calling the smartform function module.

DATA: l_formname TYPE tdsfname,
        l_fm_name TYPE rs38l_fnam,
        l_control_param TYPE ssfctrlop,
        l_output_options TYPE ssfcompop,
        l_device LIKE itcpp-tddest VALUE 'LP01',
        l_job_info TYPE ssfcrescl .

  l_formname = text-008.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = l_formname
    IMPORTING
      fm_name            = l_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.

  l_control_param-no_dialog = 'X'.
  l_control_param-preview = 'X'.
  l_control_param-getotf = c_email.
  l_output_options-tddest = l_device.

  CALL FUNCTION l_fm_name
    EXPORTING
      wa_output_header   = wa_output_header
      control_parameters = l_control_param
      output_options     = l_output_options
      user_settings      = ''
    IMPORTING
      job_output_info    = l_job_info
    TABLES
      it_po              = it_po
    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.

  IF c_email = 'X'. "If this checkbox is selected, then send email.    
    PERFORM prepare_and_send_mail USING l_job_info.
  ENDIF.
ENDFORM.                    " DISPLAY_SMARTFORM

Continued in the next post.......................