Current Position:Home > Smartforms: How to CC email & Include a few lines of Text in Body of email?

Smartforms: How to CC email & Include a few lines of Text in Body of email?

Update:10-11Source: network consolidation
Advertisement
I have created a smartform and have it outputting PDf documents and sending then via e-mail and it all works great.  Except u2026 now I would like to CC someone and also have a few lines of text in the e-mail.  Does anyone have any ideas?
Here is my code:
IF p_mail = 'X'.
    wa_ctrlop-device = 'MAIL'.
    PERFORM mail_recipient_object.
    PERFORM mail_sender_object.
    PERFORM mail_appl_object CHANGING g_mail_app_obj.
  ENDIF.
  LOOP AT my_table.
    CONCATENATE 'ECS' comp_year izhr_emp_comp_summary-emp_lname INTO wa_outopt-tdtitle separated by space.
    CALL FUNCTION func_mod_name
      EXPORTING
        CONTROL_PARAMETERS      = wa_ctrlop
        MAIL_APPL_OBJ           = g_mail_app_obj
        MAIL_RECIPIENT          = email_recipient
        MAIL_SENDER             = email_sender
        OUTPUT_OPTIONS          = wa_outopt
        USER_SETTINGS           = u2018Xu2019
      IMPORTING
        DOCUMENT_OUTPUT_INFO    = document_output_info
        JOB_OUTPUT_INFO         = t_otfdata
      TABLES
        I_MYTABLE                 = imy_table
      EXCEPTIONS
        FORMATTING_ERROR        = 1
        INTERNAL_ERROR          = 2
        SEND_ERROR              = 3
        USER_CANCELED           = 4
        OTHERS                  = 5.
   ENDLOOP.
Determines the Recipent of the E-Mail
FORM mail_recipient_object.
  CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
    EXPORTING
      ip_mailaddr       = email_address     "E-mail Addr:Input Screen
      ip_type_id        = 'U'               "Internet Address
    IMPORTING
      ep_recipient_id   = email_recipient   "Recipient Obj Key
    EXCEPTIONS
      invalid_recipient = 1
      OTHERS            = 2.
  IF sy-subrc <> 0.
    MESSAGE e531(0u) WITH text-003.                      "Error E-Mailing
  ENDIF.
ENDFORM.    "mail_recipient_object.
*Sender of E-mail
FORM mail_sender_object.
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
    EXPORTING
      ip_sender      = sy-uname             "User Logged in
    IMPORTING
      ep_sender_id   = email_sender
    EXCEPTIONS
      invalid_sender = 1
      OTHERS         = 2.
  IF sy-subrc <> 0.
    MESSAGE e531(0u) WITH text-e15.                      "Error E-Mailing
  ENDIF.
ENDFORM.    "mail_sender_object.
*Creates Mail Application Object to E-Mail Smartform
FORM mail_appl_object CHANGING g_mail_app_obj.
  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.

The Best Answer

Advertisement
Get rid of the smartform-based mail sending code if you can.  That interface is quite old, simplistic, and inflexible (i.e., you can't do what you're asking).  I would use class CL_BCS.  It's especially much easier once you have developed a (custom) standard email wrapper class for sending various types of emails, including smartform-based PDF-attached emails.  You can even go with HTML and dress-up your emails a bit.

Recommended Content

Database error: [Table 'ac_posts' is marked as crashed and should be repaired]

SELECT * FROM ac_posts WHERE `ID` IN (2919895,4299991,4847252,3945915,1688080,4850341,3955224,3756874,1648337,2184912,3944703,4285777,3880031,2307810,5150285,3963055,2020816,3460742,2823222,4999661,1148184,2260345,1407668,704333,1380266,2383119,4892844,3080485,3679595,2536739,1214006) LIMIT 15;