<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Send E-Mail in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841923#M1318131</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send email and attachment....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a sample code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 * Fill the document data.
  DESCRIBE TABLE gt_message LINES gv_cnt.
  READ TABLE gt_message INTO gs_message
                                INDEX gv_cnt.
  gs_doc_chng-doc_size   = ( gv_cnt - 1 ) * 255 + STRLEN( gs_message ).
  gs_doc_chng-obj_langu  = sy-langu.
  gs_doc_chng-obj_name   = 'CONJOB'.
  gs_doc_chng-obj_descr  = text-017.
  gs_doc_chng-sensitivty = 'F'.
* Fill the receiver list
  gs_reclist-rec_date    = sy-datum.
  gs_reclist-rec_type    = 'U' .         " For Internet Address
  gs_reclist-com_type    = 'INT'.
  gs_reclist-notif_ndel  = c_x.
  gs_reclist-receiver    = p_email.       "Email addr of Recip
  APPEND gs_reclist TO gt_reclist.
  CLEAR gs_reclist.
  gs_packing_list-transf_bin = space.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num   = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE gt_message LINES gs_packing_list-body_num.
  gs_packing_list-doc_type   = 'RAW'.
  APPEND gs_packing_list TO gt_packing_list.
  gs_packing_list-transf_bin = c_x.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num   = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE pt_attachment LINES gs_packing_list-body_num.
  gs_packing_list-doc_type   = 'RAW'.
  gs_packing_list-obj_descr  = gv_atch_name.
  gs_packing_list-obj_name   = gv_atch_name.
  gs_packing_list-doc_size   = gs_packing_list-body_num * 255.
  APPEND gs_packing_list TO gt_packing_list.
* Send the document
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data              = gs_doc_chng
            put_in_outbox              = c_x
       TABLES
            packing_list               = gt_packing_list
            contents_txt               = gt_message
            contents_bin               = pt_attachment
            receivers                  = gt_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.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Jun 2009 13:04:42 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-06-18T13:04:42Z</dc:date>
    <item>
      <title>Send E-Mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841922#M1318130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi GURUS!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a problem to solve:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after a program that execute a automatic batch-input, I create e layout where there is a result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now..the problem is that I must send by e-mail this layout to the e-mail(s) address(es) insert on the selection scree.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I must do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help me!&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2009 13:00:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841922#M1318130</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-18T13:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Send E-Mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841923#M1318131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send email and attachment....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a sample code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
 * Fill the document data.
  DESCRIBE TABLE gt_message LINES gv_cnt.
  READ TABLE gt_message INTO gs_message
                                INDEX gv_cnt.
  gs_doc_chng-doc_size   = ( gv_cnt - 1 ) * 255 + STRLEN( gs_message ).
  gs_doc_chng-obj_langu  = sy-langu.
  gs_doc_chng-obj_name   = 'CONJOB'.
  gs_doc_chng-obj_descr  = text-017.
  gs_doc_chng-sensitivty = 'F'.
* Fill the receiver list
  gs_reclist-rec_date    = sy-datum.
  gs_reclist-rec_type    = 'U' .         " For Internet Address
  gs_reclist-com_type    = 'INT'.
  gs_reclist-notif_ndel  = c_x.
  gs_reclist-receiver    = p_email.       "Email addr of Recip
  APPEND gs_reclist TO gt_reclist.
  CLEAR gs_reclist.
  gs_packing_list-transf_bin = space.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num   = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE gt_message LINES gs_packing_list-body_num.
  gs_packing_list-doc_type   = 'RAW'.
  APPEND gs_packing_list TO gt_packing_list.
  gs_packing_list-transf_bin = c_x.
  gs_packing_list-head_start = 1.
  gs_packing_list-head_num   = 0.
  gs_packing_list-body_start = 1.
  DESCRIBE TABLE pt_attachment LINES gs_packing_list-body_num.
  gs_packing_list-doc_type   = 'RAW'.
  gs_packing_list-obj_descr  = gv_atch_name.
  gs_packing_list-obj_name   = gv_atch_name.
  gs_packing_list-doc_size   = gs_packing_list-body_num * 255.
  APPEND gs_packing_list TO gt_packing_list.
* Send the document
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
            document_data              = gs_doc_chng
            put_in_outbox              = c_x
       TABLES
            packing_list               = gt_packing_list
            contents_txt               = gt_message
            contents_bin               = pt_attachment
            receivers                  = gt_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.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2009 13:04:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841923#M1318131</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-18T13:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: Send E-Mail</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841924#M1318132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this a sample i´ve done:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


  swc_container lt_container.
  DATA:  BEGIN OF w_mail_sender.
          INCLUDE STRUCTURE swotobjid.
  DATA:  END   OF w_mail_sender.
  DATA:  BEGIN OF w_mail_receiver.
          INCLUDE STRUCTURE swotobjid.
  DATA:  END   OF w_mail_receiver.

* mail
  DATA: lo_recipient            TYPE swc_object,
        ls_persistent_recipient LIKE swotobjid,
        lo_sender               TYPE swc_object,
        ls_persistent_sender    LIKE swotobjid,
        control_parameters      TYPE ssfctrlop,
        r_input                 TYPE ssfcompop,
        ti_correo TYPE TABLE OF zficorr_coop,
        wa_correo TYPE zficorr_coop,

*       SMARTFORMS
        language    TYPE thead-tdspras,
        name        LIKE thead-tdname,
        tdname      LIKE stxh-tdname,
        formname TYPE tdsfname,
        fm_smartform TYPE rs38l_fnam.

  formname = 'ZFORM'.

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname = formname
    IMPORTING
      fm_name  = fm_smartform.

  control_parameters-device = 'MAIL'.
  control_parameters-no_dialog = 'X'.
  r_input-tdnoprev  = 'X'. "No preview
  r_input-tdnewid   = 'X'. "nueva orden spool
  r_input-tdimmed   = 'X'. "salida inmediata
  r_input-tdtitle   = 'TITLE.
  r_input-tdsuffix2 = sy-uname.
  language = sy-langu.


*   create sender (current user)
  swc_create_object lo_sender 'RECIPIENT' space.
  swc_set_element lt_container 'AddressString' sy-uname.
  swc_set_element lt_container 'TypeID' 'B'.
  swc_call_method lo_sender 'CreateAddress' lt_container.
  swc_object_to_persistent lo_sender ls_persistent_sender.

  SELECT * INTO TABLE ti_correo
  FROM zficorr_coop
  FOR ALL ENTRIES IN ti_datos
  WHERE kunnr EQ ti_datos-kunnr.

  SORT ti_datos BY kunnr dmbtr DESCENDING.

* SEND MAIL
  LOOP AT ti_correo INTO wa_correo.

* create recipient
    swc_create_object lo_recipient 'RECIPIENT' space.
    swc_set_element lt_container 'AddressString' wa_correo-correo.
    swc_set_element lt_container 'TypeID' 'U'.
    swc_call_method lo_recipient 'CreateAddress' lt_container.
    swc_object_to_persistent lo_recipient ls_persistent_recipient.

    w_mail_sender   = ls_persistent_sender.
    w_mail_receiver = ls_persistent_recipient.

*   Funcion de envio por correo electrónico
    CALL FUNCTION fm_smartform
      EXPORTING
        control_parameters = control_parameters
        mail_appl_obj      = w_mail_sender
        mail_recipient     = w_mail_receiver
        mail_sender        = w_mail_sender
        output_options     = r_input
        p_tiempo           = l_tiempo
      TABLES
        ti_output          = ti_datos.

    COMMIT WORK.
    IF sy-subrc &amp;lt;&amp;gt; 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
  ENDLOOP.
ENDFORM.                    "mail

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BYE!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Gabriel P&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Gabriel P.- on Jun 18, 2009 8:31 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Gabriel P.- on Jun 18, 2009 8:33 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Jun 2009 13:31:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/send-e-mail/m-p/5841924#M1318132</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-18T13:31:18Z</dc:date>
    </item>
  </channel>
</rss>

