<?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 Need help sending email attachment in CSV format using method in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209517#M1005940</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I need to send an email with an attachment in CSV format.&lt;/P&gt;&lt;P&gt;I have a comma delimited file (290 characters). I am using a method ( cl_hrrcf_services_mail-&amp;gt;send_web_mail),  but when I send the mail the attachment is empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know a lot of developers use function module &lt;/P&gt;&lt;P&gt;'SO_NEW_DOCUMENT_ATT_SEND_API1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anybody use method method cl_hrrcf_services_mail to do this? Any ideas on how I can do this will be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Margariet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 19 Jul 2008 14:00:07 GMT</pubDate>
    <dc:creator>SFactor</dc:creator>
    <dc:date>2008-07-19T14:00:07Z</dc:date>
    <item>
      <title>Need help sending email attachment in CSV format using method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209517#M1005940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I need to send an email with an attachment in CSV format.&lt;/P&gt;&lt;P&gt;I have a comma delimited file (290 characters). I am using a method ( cl_hrrcf_services_mail-&amp;gt;send_web_mail),  but when I send the mail the attachment is empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know a lot of developers use function module &lt;/P&gt;&lt;P&gt;'SO_NEW_DOCUMENT_ATT_SEND_API1'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anybody use method method cl_hrrcf_services_mail to do this? Any ideas on how I can do this will be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Margariet&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 14:00:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209517#M1005940</guid>
      <dc:creator>SFactor</dc:creator>
      <dc:date>2008-07-19T14:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need help sending email attachment in CSV format using method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209518#M1005941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Check this sample code: It calls a smartforms, generates a PDF and sends as attachment to external mailbox.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT ytest_email.

* This example shows how to send
*   - a simple text provided in an internal table of text lines
*   - to some internet email address.
*
* All activities done via facade CL_BCS!


INCLUDE rlb_invoice_data_declare.

DATA: send_request       TYPE REF TO cl_bcs.
DATA: text               TYPE bcsy_text.
DATA: document           TYPE REF TO cl_document_bcs.
DATA: sender             TYPE REF TO cl_sapuser_bcs.
DATA: recipient          TYPE REF TO if_recipient_bcs.
DATA: bcs_exception      TYPE REF TO cx_bcs.
DATA: sent_to_all        TYPE os_boolean.



START-OF-SELECTION.

  PERFORM main.


*---------------------------------------------------------------------*
*       FORM main                                                     *
*---------------------------------------------------------------------*
FORM main.

  DATA: ls_bil_invoice TYPE lbbil_invoice.
  DATA: lf_fm_name            TYPE rs38l_fnam.
  DATA: ls_control_param      TYPE ssfctrlop.
  DATA: ls_composer_param     TYPE ssfcompop.
  DATA: ls_recipient          TYPE swotobjid.
  DATA: ls_sender             TYPE swotobjid.
  DATA: lf_formname           TYPE tdsfname.
  DATA: ls_addr_key           LIKE addr_key.
  DATA: ls_dlv-land           LIKE vbrk-land1.
  DATA: ls_job_info           TYPE ssfcrescl.


  DATA: I_CUST TYPE  SCUSTOM.
  DATA: I_BOOK TYPE TY_BOOKINGS,
        I_CONN TYPE TY_CONNECTIONS.

 DATA: W_I_SIZE TYPE I,
      I_DOCS  TYPE TABLE OF DOCS,
      I_LINES TYPE TABLE OF TLINE.


DATA: I_OTF TYPE TSFOTF.

DATA: I_BIN TYPE SOLIX_TAB.

data: gd_buffer type string,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE.
.

DATA: WA_LINES LIKE LINE OF I_LINES,
      WA_PDF  LIKE LINE OF I_BIN.


  DATA: PDF_CONTENT        TYPE SOLIX_TAB.
  DATA: LP_PDF_SIZE        TYPE SO_OBJ_LEN.


  data: w_xstr  type xstring,
        w_len   type i.

 TRY.




*  SF_EXAMPLE_01

   CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
         EXPORTING  formname           = 'SF_EXAMPLE_01'
*                 variant            = ' '
*                 direct_call        = ' '
         IMPORTING  fm_name            = lf_fm_name
         EXCEPTIONS no_form            = 1
                    no_function_module = 2
                    OTHERS             = 3.
    IF sy-subrc &amp;lt;&amp;gt; 0.
*   error handling
    ENDIF.


    ls_control_param-getotf = 'X'.
    ls_control_param-NO_DIALOG = 'X'.

* call smartform invoice
      CALL FUNCTION lf_fm_name
           EXPORTING
                      archive_index        = toa_dara
                      archive_parameters   = arc_params
                      control_parameters   = ls_control_param
*                 mail_appl_obj        =
                      mail_recipient       = ls_recipient
                      mail_sender          = ls_sender
                      output_options       = ls_composer_param
                      user_settings        = space
                      CUSTOMER              = I_CUST
                      BOOKINGS              = I_BOOK
                      CONNECTIONS           = I_CONN
                      is_repeat            = repeat
           importing  job_output_info      = ls_job_info
*                     document_output_info =
*                     job_output_options   =
           EXCEPTIONS formatting_error     = 1
                      internal_error       = 2
                      send_error           = 3
                      user_canceled        = 4
                      OTHERS               = 5.
      IF sy-subrc = 0.

         I_OTF = LS_JOB_INFO-OTFDATA[].

      endif.



   CALL FUNCTION 'CONVERT_OTF_2_PDF'
*    EXPORTING
*      USE_OTF_MC_CMD               = 'X'
*      ARCHIVE_INDEX                =
    IMPORTING
      BIN_FILESIZE                 =   w_i_size
     TABLES
       OTF                          =  I_OTF
       DOCTAB_ARCHIVE               =  I_docs
       LINES                        =  I_LINES
*    EXCEPTIONS
*      ERR_CONV_NOT_POSSIBLE        = 1
*      ERR_OTF_MC_NOENDMARKER       = 2
*      OTHERS                       = 3
             .
   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.





* Transfer the 132-long strings to 255-long strings
LOOP AT i_lines into wa_lines.
TRANSLATE wa_lines USING '~'.
CONCATENATE gd_buffer wa_lines INTO gd_buffer.
ENDLOOP.

TRANSLATE gd_buffer USING '~'.

DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.


   CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
     EXPORTING
       INPUT_LENGTH       = w_i_size
      FIRST_LINE         = 0
      LAST_LINE          = 0
    IMPORTING
      BUFFER             =  w_xstr
     TABLES
       BINARY_TAB         = it_mess_att
    EXCEPTIONS
      FAILED             = 1
      OTHERS             = 2
             .
   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.

PDF_CONTENT = CL_DOCUMENT_BCS=&amp;gt;XSTRING_TO_SOLIX( IP_XSTRING = w_xstr ).
*     -------- create persistent send request ------------------------
      send_request = cl_bcs=&amp;gt;create_persistent( ).

*     -------- create and set document -------------------------------
*     create document from internal table with text
*      APPEND 'Hello world!' TO text.
      document = cl_document_bcs=&amp;gt;create_document(
                      i_type    = 'RAW'
                      i_TEXT    =  TEXT
                      i_length  = '21'
                      i_subject = 'FORM TEST' ).

**add attachment to document
      CALL METHOD document-&amp;gt;add_attachment
        EXPORTING  i_attachment_type    = 'PDF'
                   i_attachment_subject = 'MY ORDER CONFIRMATION'
*                   i_attachment_size    = W_len
                   i_att_content_hex   = pdf_content .

*
*
*     add document to send request
      CALL METHOD send_request-&amp;gt;set_document( document ).
*
*     --------- set sender -------------------------------------------
*     note: this is necessary only if you want to set the sender
*           different from actual user (SY-UNAME). Otherwise sender is
*           set automatically with actual user.
*
*      sender = cl_sapuser_bcs=&amp;gt;create( sy-uname ).
*      CALL METHOD send_request-&amp;gt;set_sender
*        EXPORTING
*          i_sender = sender.
*
*     --------- add recipient (e-mail address) -----------------------
*     create recipient - please replace e-mail address !!!
      recipient = cl_cam_address_bcs=&amp;gt;create_internet_address(
                                        'give email address here' ).
*
*     add recipient with its respective attributes to send request
      CALL METHOD send_request-&amp;gt;add_recipient
        EXPORTING
          i_recipient = recipient
          i_express   = 'X'.
*
*
       recipient = cl_sapuser_bcs=&amp;gt;create( sy-uname ).

       CALL METHOD send_request-&amp;gt;add_recipient
         EXPORTING
          i_recipient = recipient
          i_express   = 'X'.
*
*
*
*     ---------- send document ---------------------------------------
      CALL METHOD send_request-&amp;gt;send(
        EXPORTING
          i_with_error_screen = 'X'
        RECEIVING
          result              = sent_to_all ).
      IF sent_to_all = 'X'.
        WRITE text-003.
      ENDIF.

      COMMIT WORK.

* -----------------------------------------------------------
* *                     exception handling
* -----------------------------------------------------------
* * replace this very rudimentary exception handling
* * with your own one !!!
* -----------------------------------------------------------
    CATCH cx_bcs INTO bcs_exception.
      WRITE: text-001.
      WRITE: text-002, bcs_exception-&amp;gt;error_type.
      EXIT.

  ENDTRY.

ENDFORM.                    "main
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 19 Jul 2008 14:16:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209518#M1005941</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-19T14:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help sending email attachment in CSV format using method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209519#M1005942</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;When I open the attachment all my data is in one line and the format is not correct.&lt;/P&gt;&lt;P&gt;My internal table is comma delimited and 290 characters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can somebody please help? I am using function module FUNCTION 'SO_DOCUMENT_SEND_API1' to send the mail to a Notes email address.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Margariet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2008 10:11:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209519#M1005942</guid>
      <dc:creator>SFactor</dc:creator>
      <dc:date>2008-07-25T10:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need help sending email attachment in CSV format using method</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209520#M1005943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You must use FM  as below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO_NEW_DOCUMENT_ATT_SEND_API1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using se37 go into function module. Read its Documenation. You will find your solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rajesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2008 10:18:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-sending-email-attachment-in-csv-format-using-method/m-p/4209520#M1005943</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-07-25T10:18:59Z</dc:date>
    </item>
  </channel>
</rss>

