E-mail in ABAP

Hi Experts,
How can i send E-mail in ABAP?
I want to attach a text file to that E-mail.
Please any one can help me ASAP.
Regards
Rajendra

Hi,
Please take a look at the code below:
FORM get_name_and_date.
move username and latest date
  MOVE sy-uname TO zts0001-zcreated_by.
  MOVE sy-datum TO zts0001-zchanged_date.
select records which have been presently modified
  SELECT kunnr cdseq zaddress zcperson zcnumber FROM zts0001
  INTO TABLE it_zts0001
  WHERE zchanged_date = sy-datum.
select records based from records fetched by it_zts0001
  IF NOT it_zts0001[] IS INITIAL.
    SELECT kunnr cdseq zaddress zcperson zcnumber FROM zts_stpgeoloc
    INTO TABLE it_zts_stpgeoloc
    FOR ALL ENTRIES IN it_zts0001
    WHERE kunnr = it_zts0001-kunnr
      AND cdseq = it_zts0001-cdseq.
  ENDIF.
get number of records from zts0001
  CLEAR sy-dbcnt.
  SELECT kunnr cdseq zaddress zcperson zcnumber
  FROM zts0001
  INTO TABLE it_zts0001_count.
  IF sy-dbcnt > 0.
    lv_count_zts0001 = sy-dbcnt.
    CLEAR sy-dbcnt.
  ENDIF.
get number of records from zts_stpgeoloc
  SELECT kunnr cdseq zaddress zcperson zcnumber
  FROM zts_stpgeoloc
  INTO TABLE it_zts_stpgeoloc_count.
  IF sy-dbcnt > 0.
    lv_count_zts_stpgeoloc = sy-dbcnt.
    CLEAR sy-dbcnt.
  ENDIF.
if records in ZTS_STPGEOLOC does not match the records in ZTS0001
  IF lv_count_zts_stpgeoloc <> lv_count_zts0001.
    LOOP AT it_zts_stpgeoloc_count ASSIGNING <fs_zts_stpgeoloc_count>.
      READ TABLE it_zts0001_count WITH TABLE KEY
                                 kunnr = <fs_zts_stpgeoloc_count>-kunnr
                                 cdseq = <fs_zts_stpgeoloc_count>-cdseq.
    move records which have been deleted to itab it_del_entries
      IF sy-subrc <> 0.
        MOVE-CORRESPONDING <fs_zts_stpgeoloc_count> TO it_del_entries.
        APPEND it_del_entries.
        CLEAR it_del_entries.
      delete records from table zts_stpgeoloc
        DELETE FROM zts_stpgeoloc
        WHERE kunnr = <fs_zts_stpgeoloc_count>-kunnr
          AND cdseq = <fs_zts_stpgeoloc_count>-cdseq.
        COMMIT WORK AND WAIT.
      ENDIF.
    ENDLOOP.
  ENDIF.
if the address, contact person, contact number in table
ZTS_STPGEOLOC for a given record does not match the same record
in ZTS0001, then get old and modified address to put in message text
  LOOP AT it_zts0001 ASSIGNING <fs_zts0001>.
    READ TABLE it_zts_stpgeoloc WITH KEY kunnr = <fs_zts0001>-kunnr
                                         cdseq = <fs_zts0001>-cdseq.
    IF sy-subrc = 0.
    address
      IF it_zts_stpgeoloc-zaddress <> <fs_zts0001>-zaddress.
        lv_flag = 1.
        MOVE <fs_zts0001>-kunnr TO it_address_status-kunnr.
        MOVE <fs_zts0001>-cdseq TO it_address_status-cdseq.
        MOVE it_zts_stpgeoloc-zaddress TO it_address_status-old_address.
        MOVE <fs_zts0001>-zaddress TO it_address_status-new_address.
      ENDIF.
    person
      IF it_zts_stpgeoloc-zcperson <> <fs_zts0001>-zcperson.
        lv_flag = 1.
        MOVE <fs_zts0001>-kunnr TO it_address_status-kunnr.
        MOVE <fs_zts0001>-cdseq TO it_address_status-cdseq.
        MOVE it_zts_stpgeoloc-zcperson TO it_address_status-old_person.
        MOVE <fs_zts0001>-zcperson TO it_address_status-new_person.
      ENDIF.
    number
      IF it_zts_stpgeoloc-zcnumber <> <fs_zts0001>-zcnumber.
        lv_flag = 1.
        MOVE <fs_zts0001>-kunnr TO it_address_status-kunnr.
        MOVE <fs_zts0001>-cdseq TO it_address_status-cdseq.
        MOVE it_zts_stpgeoloc-zcnumber TO it_address_status-old_number.
        MOVE <fs_zts0001>-zcnumber TO it_address_status-new_number.
      ENDIF.
      IF NOT it_address_status IS INITIAL.
        APPEND it_address_status.
        CLEAR it_address_status.
      ENDIF.
    update table zts_stpgeoloc based from itab it_zts0001
      IF lv_flag = 1.
        CLEAR lv_flag.
        UPDATE zts_stpgeoloc SET zaddress = <fs_zts0001>-zaddress
                                 zcperson = <fs_zts0001>-zcperson
                                 zcnumber = <fs_zts0001>-zcnumber
                              WHERE kunnr = <fs_zts0001>-kunnr
                                AND cdseq = <fs_zts0001>-cdseq.
      ENDIF.
    ENDIF.
  ENDLOOP.
get e-mail addresses of controllers in table ZSHIPTO_EMAIL
  SELECT * FROM zshipto_email
  INTO TABLE it_zshipto_email
  WHERE zevent = '2'.
  IF sy-dbcnt > 0.
    IF NOT it_del_entries[] IS INITIAL.
      maildata-obj_name = 'Record Deleted in table ZTS0001'.
      maildata-obj_descr = 'Record Deleted in table ZTS0001'.
      maildata-obj_langu = sy-langu.
   records deleted in ZTS0001 and ZTS_STPGEOLOC
      CLEAR: lv_flag, lv_counter.
      LOOP AT it_zshipto_email.
        CLEAR: it_del_entries, mailtxt.
        LOOP AT it_del_entries ASSIGNING <fs_del_entries>.
        get name of dealer
          SELECT SINGLE name1 FROM kna1
          INTO <fs_del_entries>-name1
          WHERE kunnr = <fs_del_entries>-kunnr.
          IF lv_counter IS INITIAL.
            CONCATENATE: 'FYI: The ff record/s were deleted in tables'
                         'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
          ENDIF.
          APPEND mailtxt.
          CONCATENATE: 'Dealer :' <fs_del_entries>-kunnr '-'
                       <fs_del_entries>-name1
                       INTO lv_contents
                       SEPARATED BY space.
          mailtxt-line = lv_contents.
          APPEND mailtxt.
          CLEAR: mailtxt, lv_contents.
          CONCATENATE: 'Ship-To:' <fs_del_entries>-cdseq
                       INTO lv_contents
                       SEPARATED BY space.
          mailtxt-line = lv_contents.
          APPEND mailtxt.
          CLEAR: mailtxt, lv_contents.
          CONCATENATE: 'Address:' <fs_del_entries>-zaddress
                       INTO lv_contents
                       SEPARATED BY space.
          mailtxt-line = lv_contents.
          APPEND mailtxt.
          CLEAR: mailtxt, lv_contents.
          CONCATENATE: 'Contact person:' <fs_del_entries>-zcperson
                       INTO lv_contents
                       SEPARATED BY space.
          mailtxt-line = lv_contents.
          APPEND mailtxt.
          CLEAR: mailtxt, lv_contents.
          CONCATENATE: 'Contact number:' <fs_del_entries>-zcnumber
                       INTO lv_contents
                       SEPARATED BY space.
          mailtxt-line = lv_contents.
          APPEND mailtxt.
          CLEAR: mailtxt, lv_contents.
          lv_counter = 1.
        ENDLOOP.
        APPEND mailtxt.
        mailrec-receiver = it_zshipto_email-zemail.
        mailrec-rec_type  = 'U'.
        APPEND mailrec.
        CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
             EXPORTING
                  document_data              = maildata
                  document_type              = 'RAW'
                  put_in_outbox              = 'X'
                  commit_work                = 'X'
             TABLES
                 object_header              = mailtxt
                  object_content             = mailtxt
                  receivers                  = mailrec
             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.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CLEAR:    mailtxt, mailrec, lv_counter.
        REFRESH:  mailtxt, mailrec.
      ENDLOOP.
    ENDIF.
    CLEAR it_del_entries.
    REFRESH it_del_entries.
for records that were modified
    IF NOT it_address_status[] IS INITIAL.
      CLEAR maildata.
      maildata-obj_name = 'Record changed in table ZTS0001'.
      maildata-obj_descr = 'Record changed in table ZTS0001'.
      maildata-obj_langu = sy-langu.
      CLEAR lv_counter.
      LOOP AT it_zshipto_email.
        CONCATENATE: 'FYI: The ff records were changed in tables'
                     'ZTS0001 and ZTS_STPGEOLOC by user' sy-uname
                     INTO lv_contents
                     SEPARATED BY space.
        mailtxt-line =  lv_contents.
        APPEND mailtxt.
        CLEAR: mailtxt, lv_contents.
        LOOP AT it_address_status ASSIGNING <fs_address_status>.
        get name of dealer
          SELECT SINGLE name1 FROM kna1
          INTO <fs_address_status>-name1
          WHERE kunnr = <fs_address_status>-kunnr.
          APPEND mailtxt.
        address
          IF NOT <fs_address_status>-old_address IS INITIAL AND
             NOT <fs_address_status>-new_address IS INITIAL.
            CONCATENATE: 'Dealer :' <fs_address_status>-kunnr '-'
                         <fs_address_status>-name1
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
            CONCATENATE: 'Ship-To:' <fs_address_status>-cdseq
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
           CONCATENATE: 'Address from:' <fs_address_status>-old_address
                                    INTO lv_contents
                                    SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
            CONCATENATE: 'Address to  :'
                         <fs_address_status>-new_address
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
          ENDIF.
        contact person
          IF NOT <fs_address_status>-old_person IS INITIAL AND
             NOT <fs_address_status>-new_person IS INITIAL.
            append mailtxt.
           CONCATENATE: 'Dealer   :' <fs_address_status>-kunnr '-'
                        <fs_address_status>-name1
                        INTO lv_contents
                        SEPARATED BY space.
           mailtxt-line = lv_contents.
           APPEND mailtxt.
           CLEAR: mailtxt, lv_contents.
           CONCATENATE: 'Ship-To :' <fs_address_status>-cdseq
                        INTO lv_contents
                        SEPARATED BY space.
           mailtxt-line = lv_contents.
           APPEND mailtxt.
           CLEAR: mailtxt, lv_contents.
            CONCATENATE: 'Contact person from:'
                         <fs_address_status>-old_person
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
            CONCATENATE: 'Contact person to  :'
                         <fs_address_status>-new_person
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
          ENDIF.
        contact number
          IF NOT <fs_address_status>-old_number IS INITIAL AND
             NOT <fs_address_status>-new_number IS INITIAL.
           append mailtxt.
           CONCATENATE: 'Dealer   :' <fs_address_status>-kunnr '-'
                        <fs_address_status>-name1
                        INTO lv_contents
                        SEPARATED BY space.
           mailtxt-line = lv_contents.
           APPEND mailtxt.
           CLEAR: mailtxt, lv_contents.
           CONCATENATE: 'Ship-To :' <fs_address_status>-cdseq
                        INTO lv_contents
                        SEPARATED BY space.
           mailtxt-line = lv_contents.
           APPEND mailtxt.
           CLEAR: mailtxt, lv_contents.
            CONCATENATE: 'Contact number from:'
                         <fs_address_status>-old_number
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
            CONCATENATE: 'Contact number to  :'
                         <fs_address_status>-new_number
                         INTO lv_contents
                         SEPARATED BY space.
            mailtxt-line = lv_contents.
            APPEND mailtxt.
            CLEAR: mailtxt, lv_contents.
          ENDIF.
        ENDLOOP.
        APPEND mailtxt.
        CLEAR mailtxt-line.
        mailrec-receiver = it_zshipto_email-zemail.
        mailrec-rec_type  = 'U'.
        APPEND mailrec.
        CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
             EXPORTING
                  document_data              = maildata
                  document_type              = 'RAW'
                  put_in_outbox              = 'X'
                  commit_work                = 'X'
             TABLES
                 object_header              = mailtxt
                  object_content             = mailtxt
                  receivers                  = mailrec
             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.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        CLEAR:    mailtxt,  mailrec.
        REFRESH:  mailtxt, mailrec.
      ENDLOOP.
      CLEAR it_address_status.
      REFRESH it_address_status.
    ENDIF.
  ENDIF.
ENDFORM.
Regards!

Similar Messages

  • Steps involved to send a mail in abap.

    hi experts,
                can anyone help me with the process involved in  sending a mail to a specific email id obtained form database.
    it will be helpful if u can provide me with the material or the code.
    thanks in advance,
    abhilash.

    Hi,
    Please visit the links for sending a mail in ABAP:
    1. http://www.sap-img.com/fu016.htm
    2. http://www.sap-basis-abap.com/abap011.htm
    May this helps you.
    Regards.
    Deepak Sharma.

  • Send a mail via ABAP program

    Hello Experts,
    I want to send mail via ABAP program with the following requirements :
    1. Recipient is OUTLOOK email -id
    2. Sender address has to be an external email-id
    3. Send mail as CC and BCC also to other email-id.
    Is there any function module which can satisfy all the above requirements.
    Regards,
    Mansi.

    hi,
    this code will definately help you just go through it:
    firstly  exported the data to memory using the FM LIST_FROM_MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = t_listobject
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE e000(su) WITH text-001.
    ENDIF.
    then i converted it into ASCII using LIST_TO_ASCI,
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = t_xlstab
    listobject = t_listobject
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3.
    IF sy-subrc NE 0.
    MESSAGE e003(yuksdbfzs).
    ENDIF.
    This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
    cl_abap_char_utilities=>horizontal_tab.
    Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
    This will create an excel attachment.
    Sample code for formatting the data for the attachment in excel format.
    u2022     Format the data for excel file download
    LOOP AT t_xlstab INTO wa_xlstab .
    DESCRIBE TABLE t_xlstab LINES lw_cnt.
    CLEAR lw_sytabix.
    lw_sytabix = sy-tabix.
    u2022     If not new line then replace '|' by tabs
    IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
    WITH cl_abap_char_utilities=>horizontal_tab.
    MODIFY t_xlstab FROM wa_xlstab .
    CLEAR wa_xlstab.
    wa_xlstab = cl_abap_char_utilities=>newline.
    IF lw_cnt NE 0 .
    lw_sytabix = lw_sytabix + 1.
    u2022     Insert new line for the excel data
    INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
    lw_cnt = lw_cnt - 1.
    ENDIF.
    CLEAR wa_xlstab.
    ENDIF.
    ENDLOOP.
    Sample code for creating attachment and sending mail:
    FORM send_mail .
    u2022     Define the attachment format
    lw_doc_type = 'XLS'.
    u2022     Create the document which is to be sent
    lwa_doc_chng-obj_name = 'List'.
    lwa_doc_chng-obj_descr = w_subject. "Subject
    lwa_doc_chng-obj_langu = sy-langu.
    u2022     Fill the document data and get size of message
    LOOP AT t_message.
    lt_objtxt = t_message-line.
    APPEND lt_objtxt.
    ENDLOOP.
    DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
    IF lw_tab_lines GT 0.
    READ TABLE lt_objtxt INDEX lw_tab_lines.
    lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
    lwa_doc_chng-obj_langu = sy-langu.
    lwa_doc_chng-sensitivty = 'F'.
    ELSE.
    lwa_doc_chng-doc_size = 0.
    ENDIF.
    u2022     Fill Packing List For the body of e-mail
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = 'RAW'.
    APPEND lt_packing_list.
    u2022     Create the attachment (the list itself)
    DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
    u2022     Fill the fields of the packing_list for creating the attachment:
    lt_packing_list-transf_bin = 'X'.
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = lw_doc_type.
    lt_packing_list-obj_name = 'Attach'.
    lt_packing_list-obj_descr = w_docdesc.
    lt_packing_list-doc_size = lw_tab_lines * 255.
    APPEND lt_packing_list.
    u2022     Fill the mail recipient list
    lt_reclist-rec_type = 'U'.
    LOOP AT t_recipient_list.
    lt_reclist-receiver = t_recipient_list-address.
    APPEND lt_reclist.
    ENDLOOP.
    u2022     Finally send E-Mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    sent_to_all = lw_sent_to_all
    TABLES
    packing_list = lt_packing_list
    object_header = lt_objhead
    contents_bin = t_xlstab
    contents_txt = lt_objtxt
    receivers = lt_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.
    Hope it will help you
    regards
    Rahul sharma

  • How to implement  mailing in ABAP

    Hi all,
    I want to send mail from my abap program to number of recepient, at a perticular time. Is it possible in ABAP to run a perticuler module at a pericler time say 8 AM every morning?

    Hi,
    Check this link for mailing..
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    Check this link for scheduling..
    http://help.sap.com/saphelp_46c/helpdata/EN/c4/3a7f87505211d189550000e829fbbd/frameset.htm
    Thanks,
    Naren
    Message was edited by: Narendran Muthukumaran

  • Send few attachment at one mail via Abap

    Hi.
    How can send few attachments in one mail threw Abap?
    I know how to send files but how can I attach few files in one mail ?
    Thanks all,
    Rebeka

    Hi,
    Tthe following piece of logic is required to send multiple attachments in one mail.
    Loop
    * Creating the entry for the compressed attachment
            IF gv_count = 1.
              gi_objpack-head_start = 1.
              gi_objpack-head_num   = 1.
              gi_objpack-body_start = 1.
              DESCRIBE TABLE gi_objbin LINES gv_no_lines.
              gi_objpack-body_num   = gv_no_lines.
              gi_objpack-doc_size   = gv_no_lines * 255.
              gi_objpack-transf_bin = gc_x.
              gi_objpack-doc_type   = gc_pdf.
              gi_objpack-obj_name   = text-037.
              CONCATENATE text-038 gw_doc_id-object_id(10)
              INTO gi_objpack-obj_descr.
              APPEND gi_objpack.
            ELSEIF gv_count > 1.
              gi_objpack-head_start = gv_no_lines + 1.
              gi_objpack-head_num   = gv_no_lines + 1.
              gi_objpack-body_start = gv_no_lines + 1.
              DESCRIBE TABLE gi_upload LINES gv_no_lines.
              gi_objpack-body_num   = gv_no_lines.
              gi_objpack-doc_size   = gv_no_lines * 255.
              gi_objpack-transf_bin = gc_x.
              gi_objpack-doc_type   = gc_pdf.
              gi_objpack-obj_name   = text-037.
              CONCATENATE text-038 gw_doc_id-object_id(10)
              INTO gi_objpack-obj_descr.
              APPEND gi_objpack.
              DESCRIBE TABLE gi_objbin LINES gv_no_lines.
            ENDIF.
      Endloop.
    Each record in gi_objpack is an attachment, say suppose 3 records are there, then it means 3 attachments.
    gi_objbin is the attachment content, here it is a PDF File.
    Hope u know about this FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' and remaining details to pass to this FM.
    Thanks,
    Srilakshmi.

  • Set Sender of Mail from Abap

    Hi,
    I use SO_NEW_DOCUMENT_SEND_API1 function module to send a mail from abap code.
    But I want to set the sender. Can I realize it?
    Regards
    Angela

    Refer this thread -
    Fill "sender id" in SO_NEW_DOCUMENT_SEND_API1
    Regards,
    Amit

  • Function modules to send mails from ABAP

    hi
               can any one give me the function module to send mails from abap to yahoomail or gmail etc. i will be grateful if any one can provide me a sample code.
    thanks & regards
    rajesh

    Hi,
    check this site:
    http://www.sapdevelopment.co.uk/reporting/email/email_mbody.htm
    Replace the
    p_email(40)   type c default '[email protected]' .
    with ur yahoo or gmail id
    This is the FM that u needed:
    'SO_NEW_DOCUMENT_ATT_SEND_API1'
    http://www.kabai.com/abaps/z00.htm
    http://www.sapdevelopment.co.uk/reporting/email/emailhome.htm
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    /people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface
    Hope this solves your question.
    Best Regards,
    Anjali

  • Uncaught Exception occured while sending mail through abap code.

    Hi,
    Uncaught Exception occured while sending mail through abap code.Run time Errors "UNCAUGHT_EXCEPTION" occured after excuting the call method  CALL METHOD SEND_REQUEST->SEND( ).kindly help in resolving the issue.

    HI,
    Runtime Error:  UNCAUGHT_EXCEPTION details.
    Runtime Errors         UNCAUGHT_EXCEPTION
    Exception              CX_ADDRESS_BCS
    Short text
         An exception occurred that was not caught.
    What happened?
         The exception 'CX_ADDRESS_BCS' was raised, but it was not caught anywhere along
         the call hierarchy.
         Since exceptions represent error situations and this error was not
         adequately responded to, the running ABAP program 'SAPLZSEND_MAIL' has to be
         terminated.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_ADDRESS_BCS', was not caught in
        procedure "SEND_MAIL" "(FORM)", nor was it propagated by a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        An exception occurred
    How to correct the error
        If the error occures in a non-modified SAP program, you may be able to
        find an interim solution in an SAP Note.
        If you have access to SAP Notes, carry out a search with the following
        keywords:
        "UNCAUGHT_EXCEPTION" "CX_ADDRESS_BCS"
        "SAPLZSEND_MAIL" or "LZSEND_MAILU01"
        "ZSEND_EMAIL"
        If you cannot solve the problem yourself and want to send an error
        notification to SAP, include the following information:
        1. The description of the current problem (short dump)
           To save the description, choose "System->List->Save->Local File
        (Unconverted)".
        2. Corresponding system log
           Display the system log by calling transaction SM21.
           Restrict the time interval to 10 minutes before and five minutes
        after the short dump. Then choose "System->List->Save->Local File
        (Unconverted)".
        3. If the problem occurs in a problem of your own or a modified SAP
        program: The source code of the program
           In the editor, choose "Utilities->More
        Utilities->Upload/Download->Download".
    4. Details about the conditions under which the error occurred or which
    actions and input led to the error.
    The exception must either be prevented, caught within proedure
    "SEND_MAIL" "(FORM)", or its possible occurrence must be declared in the
    RAISING clause of the procedure.
    Please help me to resolve this issue.

  • How to send mail from ABAP code?

    Hi,
    I need to send e-mail from ABAP Code .
    e.g:  If sy-subrc ne 0.
         ( send e-mail to  "[email protected]" )
           endif.
    Please provide me any Function module for this or any code.
    Correct answear will be rewarded my maximum points.
    Thanks & Regards,
    Gaurav.

    Check this code sample
    * Send mail
      maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test Subject'.
      loop at htmllines.
        mailtxt = htmllines.
        append mailtxt.
      endloop.
      mailrec-receiver = '[email protected]'.
      mailrec-rec_type  = 'U'.
      append mailrec.
      call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              = maildata
                document_type              = 'HTM'
                put_in_outbox              = 'X'
           tables
                object_header              = mailtxt
                object_content             = mailtxt
                receivers                  = mailrec
           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.
      if sy-subrc  0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    Regards.

  • Send mail from abap from internal mail id

    Hiiii,
              Is it possible to send mail from internal mail id  by using abap program ?

    Hi,
    I did't get your question, do you want to send mail using ABAP coding. If thats what is your requirement
    check out with link:
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/multiple%252battachment%252bon%252be_mail
    Tks,
    Krishna..

  • Sending e-mail from ABAP

    We need to send email to an external adress from ABAP. Does anybody know a function module or method to do this, maybe even with sample coding?
    Best regards
       Dirk

    There are some weblogs here:
    4.6x and lower:
    /people/thomas.jung3/blog/2004/09/07/sending-e-mail-from-abap--version-46d-and-lower--api-interface
    6.10 and higher:
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

  • How to Convert internal table data into text output and send mail in ABAP

    Hi All,
    Good Morning.
    Taking a glance at a code that converts internal table data to an Excel file in ABAP. also checked how to send this excel to mailing list as attachment.
    But thought of doing it without excel.
    I mean, I have an internal table which contains fields of all types (character,integer,date,time). Since it is only around 4 to 5 rows in it (output),why to convert it to excel. not required!!.  Instead I  want to send this output to User's mails as Normal mail body with No attachments.
    Could anybody please suggest me a way as to how to send internal table data as a mail ( not as an excel or PDF etc).
    as of now my findings are, it is quite complex to convert internal table data to email (Text) format. but i believe if there is some way of doing it.
    Best Regards
    Dileep VT

    here's something I have used in the past where we send out information about failed precalculation settings (which are stored in internal table gt_fail)
    notice we use gt_text as "mail body"
    TRY.
    *     -------- create persistent send request ------------------------
           gv_send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document -------------------------------
    *     create text to be sent
           wa_line = text-001.
           APPEND wa_line TO gt_text.
           CLEAR wa_line.
           APPEND wa_line TO gt_text.
           LOOP AT gt_fail ASSIGNING <fs_fail>.
             MOVE <fs_fail>-retry_count TO gv_count.
             CONCATENATE text-002
                         <fs_fail>-setting_id
                         text-003
                         gv_count
                         INTO wa_line SEPARATED BY space.
             APPEND wa_line TO gt_text.
             CLEAR wa_line.
           ENDLOOP.
           APPEND wa_line TO gt_text.
           wa_line = text-007.
           APPEND wa_line TO gt_text.
    *     create actual document
           gv_document = cl_document_bcs=>create_document(
                           i_type    = 'RAW'
                           i_text    = gt_text
                           i_length  = '12'
                           i_subject = 'Failed Precalculation Settings!' ).
    *     add document to send request
           CALL METHOD gv_send_request->set_document( gv_document ).
    *     --------- set sender -------------------------------------------
           gv_sender = cl_sapuser_bcs=>create( sy-uname ).
           CALL METHOD gv_send_request->set_sender
             EXPORTING
               i_sender = gv_sender.
    *     --------- add recipient (e-mail address) -----------------------
           LOOP AT s_email INTO wa_email.
             MOVE wa_email-low TO gv_email.
             gv_recipient = cl_cam_address_bcs=>create_internet_address(
                                               gv_email ).
             CALL METHOD gv_send_request->add_recipient
               EXPORTING
                 i_recipient = gv_recipient
                 i_express   = 'X'.
           ENDLOOP.
    *     ---------- set to send immediately -----------------------------
           CALL METHOD gv_send_request->set_send_immediately( 'X' ).
    *     ---------- send document ---------------------------------------
           CALL METHOD gv_send_request->send(
             EXPORTING
               i_with_error_screen = 'X'
             RECEIVING
               result              = gv_sent_to_all ).
           IF gv_sent_to_all = 'X'.
             WRITE text-004.
           ENDIF.
           COMMIT WORK.
    *   exception handling
         CATCH cx_bcs INTO gv_bcs_exception.
           WRITE: text-005.
           WRITE: text-006, gv_bcs_exception->error_type.
           EXIT.
       ENDTRY.
    with the following declarations
    * TABLES                                                               *
    TABLES:
       adr6,
       rsr_prec_sett.
    * INTERNAL TABLES & WORK AREAS                                         *
    DATA:
       gt_fail          TYPE SORTED TABLE OF rsr_prec_sett
                             WITH UNIQUE KEY setting_id run_date,
       gt_text          TYPE bcsy_text,
       wa_fail          LIKE LINE OF gt_fail,
       wa_line(90)      TYPE c.
    FIELD-SYMBOLS:
       <fs_fail>        LIKE LINE OF gt_fail.
    * VARIABLES                                                            *
    DATA:
       gv_count(4)      TYPE n,
       gv_send_request  TYPE REF TO cl_bcs,
       gv_document      TYPE REF TO cl_document_bcs,
       gv_sender        TYPE REF TO cl_sapuser_bcs,
       gv_recipient     TYPE REF TO if_recipient_bcs,
       gv_email         TYPE adr6-smtp_addr,
       gv_bcs_exception TYPE REF TO cx_bcs,
       gv_sent_to_all   TYPE os_boolean.
    * SELECTION-SCREEN                                                     *
    SELECT-OPTIONS:
       s_email          FOR adr6-smtp_addr NO INTERVALS MODIF ID sel.
    DATA:
       wa_email         LIKE LINE OF s_email.

  • Sending mail thru ABAP pgm

    Hi experts,
    Can any body tell me what settings need to be done in SAP System while sending an email thru an ABAP pgm.
    Regards

    HI,
    *& Report  ZLAXMI_ALVMAIL2                                             *
    REPORT  ZLAXMI_ALVMAIL2   MESSAGE-ID ZZ       .
    TABLES: MARA, MAKT.
    DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.
    DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.
    DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    *DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    *creation of document to be sent.
    DOC_CHNG-OBJ_NAME = 'Mailing List'.
    DOC_CHNG-OBJ_DESCR = 'Materials report'.
    *type declarations
    *To store material data
    TYPES: BEGIN OF T_MARA,
            MATNR TYPE MARA-MATNR,
            PSTAT TYPE MARA-PSTAT,
            MTART TYPE MARA-MTART,
            MBRSH TYPE MARA-MBRSH,
            MEINS TYPE MARA-MEINS,
          END OF T_MARA.
    *--To store Material Description
    TYPES: BEGIN OF T_MAKT,
             MATNR TYPE MAKT-MATNR,            " Material Number
             MAKTX TYPE MAKT-MAKTX,            " Material Description
           END OF T_MAKT.
    TYPES: BEGIN OF T_FINAL,
            MATNR TYPE MARA-MATNR,
            MAKTX TYPE MAKT-MAKTX,
            PSTAT TYPE MARA-PSTAT,
            MTART TYPE MARA-MTART,
            MBRSH TYPE MARA-MBRSH,
            MEINS TYPE MARA-MEINS,
           END OF T_FINAL.
    *Internal table declarations.
    *--Internal Table to store Material Description
    DATA: IT_MAKT TYPE STANDARD TABLE OF T_MAKT,
    *--Internal Table to store Material details
          IT_MARA TYPE STANDARD TABLE OF T_MARA,
          IT_OBJTXT TYPE STANDARD TABLE OF SOLISTI1 ,    "object text
          IT_OBJPACK TYPE STANDARD TABLE OF SOPCKLSTI1 ,
                                                   " attachment table
          IT_OBJBIN TYPE STANDARD TABLE OF SOLISTI1  ,
                                                   " binary table
          IT_OBJHEAD TYPE STANDARD TABLE OF SOLISTI1  ,
                                                   " object header table
    *--Internal Table to hold Final records to download/display
          IT_FINAL TYPE STANDARD TABLE OF T_FINAL.
    DATA: IT_RECLIST TYPE STANDARD TABLE OF SOMLRECI1. "Workarea for internal table
    DATA:  X_MAKT  TYPE T_MAKT,         "Work area for IT_MAKT
           X_MARA  TYPE T_MARA,         "Work area for IT_MARA
           X_FINAL TYPE T_FINAL,       "Work area for IT_FINAL
           V_TEXT(255) TYPE C.
    *--Work area for all the internal tables used
    DATA :    WA_OBJPACK TYPE SOPCKLSTI1,
              WA_OBJHEAD TYPE SOLISTI1  ,
              WA_OBJBIN TYPE SOLISTI1   ,
              WA_OBJTXT TYPE SOLISTI1   ,
              WA_RECLIST TYPE SOMLRECI1 .
    CONSTANTS: C_TAB  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    *selection screen.
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    SELECTION-SCREEN: END OF BLOCK B1.
    *at selection screen.
    *AT SELECTION-SCREEN.
    PERFORM VALIDATE_SCREEN.
    *start of selection.
    START-OF-SELECTION.
      PERFORM GET_MARA_DETAILS.
      PERFORM GET_MAKT_DETAILS.
      PERFORM FINAL_DATA.
    *end of selection
    END-OF-SELECTION.
      PERFORM SEND_MAIL_DATA.
      PERFORM DISPLAY_DATA.
    *&      Form  validate_screen
          text
    -->  p1        text
    <--  p2        text
    *FORM VALIDATE_SCREEN .
    DATA: LV_MATNR TYPE MARA-MATNR.
    IF NOT S_MATNR[] IS INITIAL.
       SELECT MATNR INTO
             LV_MATNR
             UP TO 1 ROWS
             FROM MARA
             WHERE MATNR IN S_MATNR.
       ENDSELECT.
    ENDIF.
    IF SY-SUBRC <> 0.
       MESSAGE E000 WITH 'Invalid material'.
    ENDIF.
    *ENDFORM.                    " validate_screen
    *&      Form  get_mara_details
          text
    -->  p1        text
    <--  p2        text
    FORM GET_MARA_DETAILS .
      SELECT MATNR
             PSTAT
             MTART
             MBRSH
             MEINS
             INTO TABLE IT_MARA
             FROM
             MARA WHERE
              MATNR IN S_MATNR.
      IF SY-SUBRC <> 0.
        MESSAGE I000 WITH 'No doc found'.
      ENDIF.
      SORT IT_MARA BY MATNR.
      DELETE ADJACENT DUPLICATES FROM IT_MARA COMPARING MATNR.
    ENDFORM.                    " get_mara_details
    *&      Form  get_makt_details
          text
    -->  p1        text
    <--  p2        text
    FORM GET_MAKT_DETAILS .
      SELECT MATNR
             MAKTX
           FROM MAKT
           INTO TABLE IT_MAKT
           FOR ALL ENTRIES IN IT_MARA
           WHERE MATNR = IT_MARA-MATNR AND
                 SPRAS = SY-LANGU.
    ENDFORM.                    " get_makt_details
    *&      Form  final_data
          text
    -->  p1        text
    <--  p2        text
    FORM FINAL_DATA .
      LOOP AT IT_MARA INTO X_MARA.
        CLEAR X_FINAL.
        READ TABLE IT_MAKT INTO X_MAKT WITH KEY MATNR = X_MARA-MATNR.
        IF SY-SUBRC = 0.
          X_FINAL-MAKTX = X_MAKT-MAKTX.
        ENDIF.
        X_FINAL-MATNR = X_MARA-MATNR.
        X_FINAL-PSTAT = X_MARA-PSTAT.
        X_FINAL-MTART = X_MARA-MTART.
        X_FINAL-MBRSH = X_MARA-MBRSH.
        X_FINAL-MEINS = X_MARA-MEINS.
        APPEND X_FINAL TO IT_FINAL.
      ENDLOOP.
    ENDFORM.                    " final_data
    *&      Form  send_mail_data
          text
    -->  p1        text
    <--  p2        text
    FORM SEND_MAIL_DATA .
      WA_RECLIST-REC_TYPE = 'B'.
      WA_RECLIST-EXPRESS  = 'X'.
      WA_RECLIST-RECEIVER = 'DEV02'.
      APPEND WA_RECLIST TO IT_RECLIST.
      CONCATENATE 'MATERIAL DATA'(021)
                 SY-DATUM INTO DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.
    *--Mail body
      CONCATENATE 'MATERIAL DESCRIPTION'(022) 'ATTACHMENT' INTO WA_OBJTXT SEPARATED BY SPACE.
      APPEND WA_OBJTXT TO IT_OBJTXT.
      DESCRIBE TABLE IT_OBJTXT LINES TAB_LINES.
      READ TABLE IT_OBJTXT INTO WA_OBJTXT INDEX TAB_LINES .
      DOC_CHNG-DOC_SIZE =
                     ( TAB_LINES - 1 ) * 255 + STRLEN( WA_OBJTXT ).
    *-populate packing list for body text
      WA_OBJPACK-HEAD_START = 1.
      WA_OBJPACK-HEAD_NUM = 0.
      WA_OBJPACK-BODY_START = 1.
      WA_OBJPACK-BODY_NUM = TAB_LINES.
      WA_OBJPACK-DOC_TYPE = 'RAW'.
      APPEND WA_OBJPACK TO IT_OBJPACK.
      CLEAR WA_OBJPACK.
    *--for attachment
    *--Populate Column headings
      CONCATENATE TEXT-040   " Material Number
                  TEXT-041   " Material Description
                  TEXT-042   " Maintenence status
                  TEXT-043   " Material type
                  TEXT-044   " Industry sector
                  TEXT-045   " Base unit of measure
                  INTO V_TEXT SEPARATED BY C_TAB.
    CONCATENATE V_TEXT
                 C_CR_LF
                 INTO V_TEXT.
      WA_OBJBIN = V_TEXT.
      APPEND WA_OBJBIN TO IT_OBJBIN.
      CLEAR  WA_OBJBIN.
    *--Populate Data to the attachment
      LOOP AT IT_FINAL INTO X_FINAL.
        CONCATENATE X_FINAL-MATNR
                    X_FINAL-MAKTX
                    X_FINAL-PSTAT
                    X_FINAL-MTART
                    X_FINAL-MBRSH
                    X_FINAL-MEINS
                   INTO V_TEXT SEPARATED BY C_TAB.
    *--Go to next line after this record.
       CONCATENATE V_TEXT
                   C_CR_LF
                   INTO V_TEXT.
        WA_OBJBIN = V_TEXT.
        APPEND WA_OBJBIN TO IT_OBJBIN.
        CLEAR  WA_OBJBIN.
      ENDLOOP.
    CLEAR : TAB_LINES.
      DESCRIBE TABLE IT_OBJBIN LINES TAB_LINES.
    *1ST ATTACHMENT :  MAT 5000 PLANT
    *2ND ATT        : MAT 5010 PLANTS
      SORT IT_FINAL BY MEINS.
      DATA : V_BEGIN TYPE SY-TABIX,
             V_END   TYPE SY-TABIX.
      LOOP AT IT_FINAL INTO X_FINAL.
        AT END OF MEINS.
          IF V_BEGIN IS INITIAL.
            V_BEGIN = 1.
          ELSE.
            V_BEGIN = V_END + 1.
          ENDIF.
          V_END = SY-TABIX.
          WA_OBJPACK-TRANSF_BIN = 'X'.
          WA_OBJPACK-HEAD_START = 1.
          WA_OBJPACK-HEAD_NUM = 1.
          WA_OBJPACK-BODY_START = V_BEGIN.
          WA_OBJPACK-BODY_NUM = V_END.
          WA_OBJPACK-DOC_TYPE = 'RAW' .
          WA_OBJPACK-OBJ_NAME = 'MATERIAL'.
          WA_OBJPACK-OBJ_DESCR = 'attachment'.
          WA_OBJPACK-DOC_SIZE = TAB_LINES * 255.
          APPEND WA_OBJPACK TO IT_OBJPACK.
        ENDAT.
      ENDLOOP.
    *-populate object header(attachment name)
      WA_OBJHEAD = 'MATERIAL DETAILS'.
      APPEND WA_OBJHEAD TO IT_OBJHEAD.
      CLEAR  WA_OBJHEAD.
    *-packing list for attachment
      WA_OBJPACK-TRANSF_BIN = 'X'.
      WA_OBJPACK-HEAD_START = 1.
      WA_OBJPACK-HEAD_NUM = 1.
      WA_OBJPACK-BODY_START = 1.
      WA_OBJPACK-BODY_NUM = TAB_LINES .
      WA_OBJPACK-DOC_TYPE = 'RAW' .
      WA_OBJPACK-OBJ_NAME = 'MATERIAL'.
      WA_OBJPACK-OBJ_DESCR = 'ATTACHMENT DESCRIPTION'.
      WA_OBJPACK-DOC_SIZE = TAB_LINES * 255.
      APPEND WA_OBJPACK TO IT_OBJPACK.
      CLEAR  WA_OBJPACK.
    *-Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = DOC_CHNG
          PUT_IN_OUTBOX              = 'X'
          COMMIT_WORK                = 'X'
        TABLES
          PACKING_LIST               = IT_OBJPACK
          OBJECT_HEADER              = IT_OBJHEAD
          CONTENTS_BIN               = IT_OBJBIN
          CONTENTS_TXT               = IT_OBJTXT
          RECEIVERS                  = IT_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.
      IF SY-SUBRC <> 0.
        MESSAGE E000 WITH 'Error occurred in sending mail'(039).
      ELSE.
        MESSAGE I000 WITH 'Mail sent'(010).
      ENDIF.
    ENDFORM.                    " send_mail_data
    *&      Form  DISPLAY_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_DATA .
      WRITE :/ SY-ULINE.
      WRITE:/1 SY-VLINE,
              2 'Material No'(024),
             19 SY-VLINE,
             20 'Material Description'(025),
             61 SY-VLINE,
             62 'Maintainence Status'(026),
             71 SY-VLINE,
             72 'Material type'(027),
             89 SY-VLINE,
             90 'Industry sector'(028),
             107 SY-VLINE,
             108 'Base unit of measure'(029),
             125 SY-VLINE.
      WRITE:/1 SY-VLINE,
             19 SY-VLINE,
             61 SY-VLINE,
             71 SY-VLINE,
             89 SY-VLINE,
             107 SY-VLINE,
             125 SY-VLINE.
      WRITE :/ SY-ULINE.
    ENDFORM.                    " DISPLAY_DATA
    Regards,
    Laxmi.

  • Sending E-Mail with ABAP List as Attachment with custom Extension

    Hello everyone.
    I have the following problem:
    I want to send a ABAP list as an attachment to an external e-mail address with a <b>custom file extension</b>.
    Everything works fine, exept the thing with the file extension.
    I am using FB 'SO_NEW_DOCUMENT_ATT_SEND_API1'.
    When I choose 'ALI' as Packing_List-Doc_Type everything works fine, but the attached file has the extension 'txt'.
    When I choose e.g. 'lbl' as Doc_Type, the extension is correct, but the file contains invalid data.
    Packinglist code:
    <i>AttType = 'ALI'.
    Describe Table ObjBin Lines TabLines.
    Read Table ObjBin Index TabLines.
    ObjPack-Doc_Size = ( TabLines - 1 ) * 255 + strlen( ObjBin ).
    ObjPack-Transf_Bin = 'X'.
    ObjPack-Head_Start = 1.
    ObjPack-Head_Num = 1. "0.
    ObjPack-Body_Start = 1.
    ObjPack-Body_Num = TabLines.
    ObjPack-Doc_Type = AttType.
    ObjPack-Obj_Name = 'ATTACHMENT'.
    ObjPack-Obj_Descr = cFileName.
    Append ObjPack.</i>
    function call:
    <i>Call Function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                Document_Data              = DocData
                Put_in_Outbox              = 'X'
           TABLES
                Packing_List               = ObjPack
                Object_Header              = ObjHeader
                Contents_Bin               = ObjBin
                Contents_Txt               = ObjTxt
                Receivers                  = RecList
           EXCEPTIONS
                Too_Many_Recievers         = 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.</i>
    Thanks for your help,
    Arndt

    Hi,
    look here:
    Re: How to email an attachment with more than 255 characters?
    Andreas

  • To post a mail from ABAP program

    dear friends
                  how to post a mail to SAP inbox of a particular user from ABAP program.

    get the spool no of the program
    we have standard program rstxpdf4  through that convert it to pdf
    and through f.m SO_NEW_DOCUMENT_ATT_SEND_API1 u can send mail.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
       EXPORTING
         DOCUMENT_DATA                    = x_document_data
         PUT_IN_OUTBOX                    = 'X'
         COMMIT_WORK                      = 'X'
       TABLES
         PACKING_LIST                     = it_packing_list
         CONTENTS_BIN                     = it_contents_bin
         CONTENTS_TXT                     = it_contents_txt
         RECEIVERS                        = it_receivers
      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 .
    IF SY-SUBRC <> 0.
       retcode = sy-subrc.
       perform protocol_update.
    else .

Maybe you are looking for

  • Adobe Photoshop Elements 9 - Canon EOS5D Mkiii - RAW images

    I have Photoshop Elements 9 and Premiere Elements 9 installed on my iMac, operating system Version 10.9.4. I have upgraded my Canon EOS 5d Mki to a Mkiii and downloaded Adobe's Plug-in 6.5 update but I am unable to open RAW images from the Mkiii in E

  • JDBC Sender for MS Access (how to?)

    Hi experts, I would like to read a MS Access DB allocated in an external server, but I am still a bit confused after reading many threads and blogs about this issue. Most of the people says no driver installation is needed when PI is running on Windo

  • Security update 2015-002

    Hi there I recently installed the lastest update entitled Security update 2015-002. So all seemed fine till I opened Mac Mail and it asks me for my password as there is no icloud mail account set up. It may be a bit stupid of me but I keep my passwor

  • Too many photos on iphoto

    Should I create several libraries to manage a large amount of photos , or can i load all 10,000 photos without causing slowdowns .

  • SAP 720 - Use New Editor Problem

    Hello Experts; Today I installed sap gui 720 on my computer. I want to use special development properties at SAP when abap development. For example : Bold Select statement or case-when macros or yellow break-point etc. But Now I'm not using new abap