Sending sapscript form to an external mail

i need to send sapscript form to an external mail like for example a yahoo mail from SAP. i need an ABAP code that performs this function. its urgent, please

1) REPORT PROGRAM  - RSTXPDFT4 ,
FIRST GENERATE SPOOL REQUEST THEN DOWNLOAD SAPSCRIPT TO PDF FILE ON LOCAL PC.
2) copy this code to send this downloaded form to external mail -
*& Report  ZGILL_SENDMAIL_PDF                                          *
REPORT  ZGILL_SENDMAIL_PDF                      .
INCLUDE ZGILL_INCMAIL.  "SEE BELOW FOR INCLUDE PROGRAM CODE.
* DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
* SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case DEFAULT '[email protected]'.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY DEFAULT 'C:TEMPSALARY_SLIP1.PDF'.
* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
* START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
* FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
* CHECK_DOS_FORMAT =
IMPORTING
* DRIVE =
EXTENSION = extension
NAME = name
* NAME_WITH_EXT =
* PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
**********************iNCLUDE pROGRAM*********************************************
*&  Include           ZGILL_INCMAIL                                    *
* Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
* FORM
FORM ml_customize USING objname objdesc.
*----------- Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
*--------- Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
* FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
* FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
* FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
*--------- Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
* IMPORTING
* COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
* Header Data
* Already Done Thru FM
* Main Text
* Already Done Thru FM
* Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
* Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
* Receiver List
* Already done thru fm
ENDFORM. "ml_prepare
* FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
* CONTENTS_HEX = objhex
* OBJECT_PARA =
* object_parb =
receivers = 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 ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
* FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
*-------------- Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
*------------- Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
* FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
*-------- Data
DATA : pos TYPE i.
DATA : len TYPE i.
*------------ Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
***********************INCLUDE END*********************************

Similar Messages

  • Sending sapscript form by email

    dear experts
    i want to send  sapscript forms by email from sap. how is it done. is there any configuration that needs to be done

    Hello,
    I have done in case where we are sending to an external mail id.
    Check the code it may help u.
    REPORT Z_SCRIPT .
    DATA: itcpo LIKE itcpo,
          tab_lines LIKE sy-tabix.
    Variables for EMAIL functionality
    DATA: maildata   LIKE sodocchgi1.
    DATA: mailpack   LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: mailhead   LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: mailbin    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: mailtxt    LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: mailrec    LIKE somlrec90 OCCURS 0  WITH HEADER LINE.
    DATA: solisti1   LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    PERFORM send_form_via_email.
          FORM  SEND_FORM_VIA_EMAIL                                      *
    FORM  send_form_via_email.
      CLEAR:    maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.
      REFRESH:  mailtxt, mailbin, mailpack, mailhead, mailrec.
    Creation of the document to be sent File Name
      maildata-obj_name = 'TEST'.
    Mail Subject
      maildata-obj_descr = 'Subject'.
    Mail Contents
      mailtxt-line = 'Here is your file'.
      APPEND mailtxt.
    Prepare Packing List
      PERFORM prepare_packing_list.
    Set recipient - email address here!!!
      mailrec-receiver = '[email protected]'.
      mailrec-rec_type  = 'U'.
      APPEND mailrec.
    Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                document_data              = maildata
                put_in_outbox              = ' '
           TABLES
                packing_list               = mailpack
                object_header              = mailhead
                contents_bin               = mailbin
                contents_txt               = mailtxt
                receivers                  = mailrec
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                operation_no_authorization = 4
                OTHERS                     = 99.
    ENDFORM.
         Form  PREPARE_PACKING_LIST
    FORM prepare_packing_list.
      CLEAR:    mailpack, mailbin, mailhead.
      REFRESH:  mailpack, mailbin, mailhead.
      DESCRIBE TABLE mailtxt LINES tab_lines.
      READ TABLE mailtxt INDEX tab_lines.
      maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).
    Creation of the entry for the compressed document
      CLEAR mailpack-transf_bin.
      mailpack-head_start = 1.
      mailpack-head_num = 0.
      mailpack-body_start = 1.
      mailpack-body_num = tab_lines.
      mailpack-doc_type = 'RAW'.
      APPEND mailpack.
    Creation of the document attachment
    This form gets the OTF code from the SAPscript form.
    If you already have your OTF code, I believe that you may
    be able to skip this form.  just do the following code, looping thru
    your SOLISTI1 and updating MAILBIN.
      PERFORM get_otf_code.
      LOOP AT solisti1.
        MOVE-CORRESPONDING solisti1 TO mailbin.
        APPEND mailbin.
      ENDLOOP.
      DESCRIBE TABLE mailbin LINES tab_lines.
      mailhead = 'TEST.OTF'.
      APPEND mailhead.
    Creation of the entry for the compressed attachment
      mailpack-transf_bin = 'X'.
      mailpack-head_start = 1.
      mailpack-head_num = 1.
      mailpack-body_start = 1.
      mailpack-body_num = tab_lines.
      mailpack-doc_type = 'OTF'.
      mailpack-obj_name = 'TEST'.
      mailpack-obj_descr = 'Subject'.
      mailpack-doc_size = tab_lines * 255.
      APPEND mailpack.
    ENDFORM.
         Form  GET_OTF_CODE
    FORM  get_otf_code.
      DATA: BEGIN OF otf OCCURS 0.
              INCLUDE STRUCTURE itcoo .
      DATA: END OF otf.
      DATA: itcpo LIKE itcpo.
      DATA: itcpp LIKE itcpp.
      CLEAR itcpo.
      itcpo-tdgetotf = 'X'.
    Start writing OTF code
      CALL FUNCTION 'OPEN_FORM'
           EXPORTING
                form     = 'Z08V3_COLLI'
                language = sy-langu
                options  = itcpo
                dialog   = ' '
           EXCEPTIONS
                OTHERS   = 1.
      CALL FUNCTION 'START_FORM'
           EXCEPTIONS
                error_message = 01
                OTHERS        = 02.
      CALL FUNCTION 'WRITE_FORM'
           EXPORTING
                window        = 'MAIN'
           EXCEPTIONS
                error_message = 01
                OTHERS        = 02.
    Close up Form and get OTF code
      CALL FUNCTION 'END_FORM'
           EXCEPTIONS
                error_message = 01
                OTHERS        = 02.
      MOVE-CORRESPONDING itcpo TO itcpp.
      CALL FUNCTION 'CLOSE_FORM'
           IMPORTING
                result  = itcpp
           TABLES
                otfdata = otf
           EXCEPTIONS
                OTHERS  = 1.
    Move OTF code to structure SOLI form email
      CLEAR solisti1. REFRESH solisti1.
      LOOP AT otf.
        solisti1-line = otf.
        APPEND solisti1.
      ENDLOOP.
    ENDFORM.
    I am sending to [email protected].
    So proceed in similar manner and let me know if u face any problem.
    Regards

  • H can we send script form to client through mail.

    h can we send script form to client through mail.

    <<removed by moderator>>
    Search SDN for more details on these...
    Thanks,
    Anmol.
    Edited by: kishan P on Apr 6, 2011 11:49 AM

  • Corrupt file attachment when sending sapscript form by mail

    i have requirment to send sapscript through mail but when open my attachment it is giving file is corrupted.let me know where i am wrong
    i am specifying the code here
    CALL FUNCTION 'CONVERT_OTF'
       EXPORTING
         format                      = 'PDF'
    *     MAX_LINEWIDTH               = 132
    *     ARCHIVE_INDEX               = ' '
    *     COPYNUMBER                  = 0
    *     ASCII_BIDI_VIS2LOG          = ' '
    *     PDF_DELETE_OTFTAB           = ' '
    *     PDF_USERNAME                = ' '
       IMPORTING
         bin_filesize                = binfilesize
    *     BIN_FILE                    =
        TABLES
          otf                         = datab[]
          lines                       = pdftab[]
       EXCEPTIONS
         ERR_MAX_LINEWIDTH           = 1
         ERR_FORMAT                  = 2
         ERR_CONV_NOT_POSSIBLE       = 3
         ERR_BAD_OTF                 = 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.
      REFRESH it_pdf[].
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
        EXPORTING
          line_width_dst              = '255'
        TABLES
          content_in                  = pdftab[]
          content_out                 = it_pdf[]
        EXCEPTIONS
          err_line_width_src_too_long = 1
          err_line_width_dst_too_long = 2
          err_conv_failed             = 3
          OTHERS                      = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ELSE.
        "Subject of the mail.
        w_document_data-obj_name  = 'MAIL_TO_HEAD'.
        w_document_data-obj_descr = 'Regarding Mail Program by SAP ABAP'.
        "Body of the mail
        w_body_msg = 'This is body of mail msg.'.
        APPEND w_body_msg TO i_body_msg.
        CLEAR  w_body_msg.
        "Write Packing List for Body
        DESCRIBE TABLE i_body_msg LINES g_tab_lines.
        w_packing_list-head_start = 1.
        w_packing_list-head_num   = 0.
        w_packing_list-body_start = 1.
        w_packing_list-body_num   = g_tab_lines.
        w_packing_list-doc_type   = 'RAW'.
        APPEND w_packing_list TO i_packing_list.
        CLEAR  w_packing_list.
        "Write Packing List for Attachment
        w_packing_list-transf_bin = 'X'.
        w_packing_list-head_start = 1.
        w_packing_list-head_num   = 0.
        w_packing_list-body_start = 1.
        DESCRIBE TABLE it_pdf LINES w_packing_list-body_num.
        w_packing_list-doc_type   = 'PDF'.
        w_packing_list-obj_descr  = 'PDF Attachment'.
        w_packing_list-obj_name   = 'PDF_ATTACHMENT'.
        w_packing_list-doc_size   = w_packing_list-body_num * 255.
        APPEND w_packing_list TO i_packing_list.
        CLEAR  w_packing_list.
        "Fill the document data and get size of attachment
        w_document_data-obj_langu  = sy-langu.
        READ TABLE i_body_msg INTO w_body_msg INDEX g_tab_lines.
        w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_body_msg ).
        "Receivers List.
        w_receivers-rec_type   = 'U'."Internet address
        w_receivers-receiver   = p_mail.
        w_receivers-com_type   = 'INT'.
        w_receivers-notif_del  = 'X'.
        w_receivers-notif_ndel = 'X'.
        APPEND w_receivers TO i_receivers .
        CLEAR:w_receivers.
        "Function module to send mail to Recipients
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data              = w_document_data
            put_in_outbox              = 'X'
            commit_work                = 'X'
          IMPORTING
            sent_to_all                = g_sent_to_all
          TABLES
            packing_list               = i_packing_list
            contents_bin               = it_pdf
            contents_txt               = i_body_msg
            receivers                  = i_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.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        else.
          MESSAGE 'Mail Successfully Sent' type 'S'.
        ENDIF.
    Edited by: sam_ins123524 on Oct 8, 2010 9:31 AM
    Edited by: sam_ins123524 on Oct 8, 2010 9:33 AM
    Moderator message: subject corrected for you, please use a more descriptive one next time, also use code tags.
    Edited by: Thomas Zloch on Oct 8, 2010 10:51 AM

    Hi,
    Once you get otf data, Use FM 'SX_OBJECT_CONVERT_OTF_PDF' to convert it to PDF. Then use CONTENT_BIN to send mail.
    Refer below code:
    * Converting OTF data to single line
      LOOP AT I_OTF INTO WA_OTF.
        CONCATENATE WA_OTF-TDPRINTCOM WA_OTF-TDPRINTPAR INTO WA_PDF.
        MOVE WA_PDF TO WA_CONTENT_TXT.
        APPEND WA_CONTENT_TXT TO I_CONTENT_TXT.
        CLEAR: WA_CONTENT_TXT.
      ENDLOOP.
    * Converting to PDF Format
      CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
        EXPORTING
          FORMAT_SRC      = C_OTF
          FORMAT_DST      = C_PDF
          DEVTYPE         = C_PRINTER
        CHANGING
          TRANSFER_BIN    = WA_TRANSFER_BIN
          CONTENT_TXT     = I_CONTENT_TXT
          CONTENT_BIN     = I_CONTENT_BIN
          OBJHEAD         = WA_OBJHEAD
          LEN             = V_LEN_IN.
    *- Send mail
        CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
          EXPORTING
            DOCUMENT_DATA                    = L_WA_DOCUMENT_DATA
          TABLES
            OBJECT_CONTENT                   = I_CONTENT_BIN
            RECEIVERS                        = L_I_RECEIVERS.

  • Sending sapscript form through Email

    Hi,
         I modifyed a std sapscript form for customer statement and that output i want to send to the customer through Email.So now i need a help for further what are the steps need to be do for sending that form by email.Pls be in details so that for me easy to solve this.
    Thanks,
    Rajendra.

    Hi ,
        I  am using the below code to send the form output by mail but it is not working for me.pls correct my code where i want to change so that i can solve my issues.
    DATA: itcpo LIKE itcpo,
    tab_lines LIKE sy-tabix.
    Variables for EMAIL functionality
    DATA: maildata LIKE sodocchgi1.
    DATA: mailpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: mailhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: mailbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: mailtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: mailrec LIKE somlrec90 OCCURS 0 WITH HEADER LINE.
    DATA: solisti1 LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    parameter: p_email1 like somlreci1-receiver .
    PERFORM send_form_via_email.
    FORM SEND_FORM_VIA_EMAIL *
    FORM send_form_via_email.
    CLEAR: maildata, mailtxt, mailbin, mailpack, mailhead, mailrec.
    REFRESH: mailtxt, mailbin, mailpack, mailhead, mailrec.
    Creation of the document to be sent File Name
    maildata-obj_name = 'TEST'.
    Mail Subject
    maildata-obj_descr = 'Subject'.
    Mail Contents
    mailtxt-line = 'Here is your file'.
    APPEND mailtxt.
    Prepare Packing List
    PERFORM prepare_packing_list.
    Set recipient - email address here!!!
    mailrec-receiver =  p_email1.
    mailrec-rec_type = 'U'.
    APPEND mailrec.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = maildata
    put_in_outbox = ' '
    TABLES
    packing_list = mailpack
    object_header = mailhead
    contents_bin = mailbin
    contents_txt = mailtxt
    receivers = mailrec
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    operation_no_authorization = 4
    OTHERS = 99.
    ENDFORM.
    Form PREPARE_PACKING_LIST
    FORM prepare_packing_list.
    CLEAR: mailpack, mailbin, mailhead.
    REFRESH: mailpack, mailbin, mailhead.
    DESCRIBE TABLE mailtxt LINES tab_lines.
    READ TABLE mailtxt INDEX tab_lines.
    maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).
    Creation of the entry for the compressed document
    CLEAR mailpack-transf_bin.
    mailpack-head_start = 1.
    mailpack-head_num = 0.
    mailpack-body_start = 1.
    mailpack-body_num = tab_lines.
    mailpack-doc_type = 'RAW'.
    APPEND mailpack.
    Creation of the document attachment
    This form gets the OTF code from the SAPscript form.
    If you already have your OTF code, I believe that you may
    be able to skip this form. just do the following code, looping thru
    your SOLISTI1 and updating MAILBIN.
    PERFORM get_otf_code.
    LOOP AT solisti1.
    MOVE-CORRESPONDING solisti1 TO mailbin.
    APPEND mailbin.
    ENDLOOP.
    DESCRIBE TABLE mailbin LINES tab_lines.
    mailhead = 'TEST.OTF'.
    APPEND mailhead.
    Creation of the entry for the compressed attachment
    mailpack-transf_bin = 'X'.
    mailpack-head_start = 1.
    mailpack-head_num = 1.
    mailpack-body_start = 1.
    mailpack-body_num = tab_lines.
    mailpack-doc_type = 'OTF'.
    mailpack-obj_name = 'TEST'.
    mailpack-obj_descr = 'Subject'.
    mailpack-doc_size = tab_lines * 255.
    APPEND mailpack.
    ENDFORM.
    Form GET_OTF_CODE
    FORM get_otf_code.
    DATA: BEGIN OF otf OCCURS 0.
    INCLUDE STRUCTURE itcoo .
    DATA: END OF otf.
    DATA: itcpo LIKE itcpo.
    DATA: itcpp LIKE itcpp.
    CLEAR itcpo.
    itcpo-tdgetotf = 'X'.
    Start writing OTF code
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    form = 'Z2006FICSE'
    language = sy-langu
    options = itcpo
    dialog = ' '
    EXCEPTIONS
    OTHERS = 1.
    CALL FUNCTION 'START_FORM'
    EXCEPTIONS
    error_message = 01
    OTHERS = 02.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    window = 'MAIN'
    EXCEPTIONS
    error_message = 01
    OTHERS = 02.
    Close up Form and get OTF code
    CALL FUNCTION 'END_FORM'
    EXCEPTIONS
    error_message = 01
    OTHERS = 02.
    MOVE-CORRESPONDING itcpo TO itcpp.
    CALL FUNCTION 'CLOSE_FORM'
    IMPORTING
    result = itcpp
    TABLES
    otfdata = otf
    EXCEPTIONS
    OTHERS = 1.
    Move OTF code to structure SOLI form email
    CLEAR solisti1. REFRESH solisti1.
    LOOP AT otf.
    solisti1-line = otf.
    APPEND solisti1.
    ENDLOOP.
    ENDFORM.
       Hope i can expect the feedback soon from you guys.
    Thanks,
    Rajendra.

  • Sending from Business workplace to External mail ID

    Hi,
    Please Some help me on this issue am getting below error  when am trying to send mail from Business Workplace to External Mail
    Cannot process message , no route from SAPUSER TO abc123 at gmail dot com
    I done configuration by refereeing below.
    Please follow these steps:
    1.) tcode = SCOT
    2.) double click SMTP
    3.) under "SMTP Connection" section, fill in your mail host IP(ex: webmail.sap.com) and the port number(25) and code page = No conversion.
    4.) under "Supported address types", make sure Internet is checked, and click on "Set". The Address area has to be *
    5.) To test route,
    SCOT -->Utilities --> Routing test
    RecipientAddr.type = INT
    Recipient addr. = abc.xyz at sap dot com
    6.) You also need to set the Default Domain.
    SCOT --> Settings --> Default Domains (webmail.sap.com)
    7.)Now go to tcode SBWP,compose a mail and in the recipient address,enter abc.xyz at sap dot com and send.
    8.) Come back to SCOT and click on Utilities-->Start send process(CtrlF7) and execute.+
    Thanks,
    GAL

    Hi
    Same problem with me.
    Mails are not sending to external mail id.
    Pls help me out!
    Regards.

  • Issue in External send - smart forms

    hi All,
    i have written a new print program for smart form and have assigned it to zoutput type.
    The print preview and spool are perfectly fine.
    when i give the medium as external send, it is not sending any attachmnet to the external mail id i gave.
    my code is as follows.
          PERFORM set_print_param USING  ls_addr_key
                                         ls_dlv-land
                                CHANGING ls_control_param
                                         ls_composer_param
                                         ls_recipient
                                         ls_sender
                                         ret.
    FORM SET_PRINT_PARAM USING    IS_ADDR_KEY LIKE ADDR_KEY
                                  IS_DLV-LAND LIKE VBRK-LAND1
                         CHANGING CS_CONTROL_PARAM TYPE SSFCTRLOP
                                  CS_COMPOSER_PARAM TYPE SSFCOMPOP
                                  CS_RECIPIENT TYPE  SWOTOBJID
                                  CS_SENDER TYPE  SWOTOBJID
                                  RET TYPE SY-SUBRC.
      DATA: LS_ITCPO     TYPE ITCPO.
      DATA: LF_REPID     TYPE SY-REPID.
      DATA: LF_DEVICE    TYPE TDDEVICE.
      DATA: LS_RECIPIENT TYPE SWOTOBJID.
      DATA: LS_SENDER    TYPE SWOTOBJID.
      LF_REPID = SY-REPID.
      CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
           EXPORTING
                PI_NAST       = NAST
                PI_COUNTRY    = IS_DLV-LAND
                PI_ADDR_KEY   = IS_ADDR_KEY
                PI_REPID      = LF_REPID
                PI_SCREEN     = XSCREEN
           IMPORTING
                PE_RETURNCODE = RET
                PE_ITCPO      = LS_ITCPO
                PE_DEVICE     = LF_DEVICE
                PE_RECIPIENT  = CS_RECIPIENT
                PE_SENDER     = CS_SENDER.
      IF RET = 0.
        MOVE-CORRESPONDING LS_ITCPO TO CS_COMPOSER_PARAM.
      CS_CONTROL_PARAM-NO_OPEN
      CS_CONTROL_PARAM-NO_CLOSE
        CS_CONTROL_PARAM-DEVICE      = LF_DEVICE.
        CS_CONTROL_PARAM-NO_DIALOG   = 'X'.
        CS_CONTROL_PARAM-PREVIEW     = XSCREEN.
        CS_CONTROL_PARAM-GETOTF      = LS_ITCPO-TDGETOTF.
        CS_CONTROL_PARAM-LANGU       = NAST-SPRAS.
      CS_CONTROL_PARAM-REPLANGU1
      CS_CONTROL_PARAM-REPLANGU2
      CS_CONTROL_PARAM-REPLANGU3
      CS_CONTROL_PARAM-STARTPAGE
      ENDIF.
    ENDFORM.         
    after this i am calling smart form with all the required parameters.
    CALL FUNCTION gv_function
        EXPORTING
          control_parameters   = ls_control_param
          output_options       = ls_composer_param
          archive_index        = toa_dara
          archive_parameters   = arc_params
          mail_recipient       = ls_recipient
          mail_sender          = ls_sender
          user_settings        = space
        IMPORTING
            JOB_OUTPUT_INFO = ls_job_info
        TABLES
          zmm_purord_at    = zmm_purord_at
        EXCEPTIONS
          formatting_error = 1
          internal_error   = 2
          send_error       = 3
          user_canceled    = 4
          OTHERS           = 5.
    i am not getting any mail to the desired mail id.
    Any pointers to this would be highly appreciated.
    Regards,
    Sreekanth

    hi All,
    i have written a new print program for smart form and have assigned it to zoutput type.
    The print preview and spool are perfectly fine.
    when i give the medium as external send, it is not sending any attachmnet to the external mail id i gave.
    my code is as follows.
          PERFORM set_print_param USING  ls_addr_key
                                         ls_dlv-land
                                CHANGING ls_control_param
                                         ls_composer_param
                                         ls_recipient
                                         ls_sender
                                         ret.
    FORM SET_PRINT_PARAM USING    IS_ADDR_KEY LIKE ADDR_KEY
                                  IS_DLV-LAND LIKE VBRK-LAND1
                         CHANGING CS_CONTROL_PARAM TYPE SSFCTRLOP
                                  CS_COMPOSER_PARAM TYPE SSFCOMPOP
                                  CS_RECIPIENT TYPE  SWOTOBJID
                                  CS_SENDER TYPE  SWOTOBJID
                                  RET TYPE SY-SUBRC.
      DATA: LS_ITCPO     TYPE ITCPO.
      DATA: LF_REPID     TYPE SY-REPID.
      DATA: LF_DEVICE    TYPE TDDEVICE.
      DATA: LS_RECIPIENT TYPE SWOTOBJID.
      DATA: LS_SENDER    TYPE SWOTOBJID.
      LF_REPID = SY-REPID.
      CALL FUNCTION 'WFMC_PREPARE_SMART_FORM'
           EXPORTING
                PI_NAST       = NAST
                PI_COUNTRY    = IS_DLV-LAND
                PI_ADDR_KEY   = IS_ADDR_KEY
                PI_REPID      = LF_REPID
                PI_SCREEN     = XSCREEN
           IMPORTING
                PE_RETURNCODE = RET
                PE_ITCPO      = LS_ITCPO
                PE_DEVICE     = LF_DEVICE
                PE_RECIPIENT  = CS_RECIPIENT
                PE_SENDER     = CS_SENDER.
      IF RET = 0.
        MOVE-CORRESPONDING LS_ITCPO TO CS_COMPOSER_PARAM.
    *   CS_CONTROL_PARAM-NO_OPEN
    *   CS_CONTROL_PARAM-NO_CLOSE
        CS_CONTROL_PARAM-DEVICE      = LF_DEVICE.
        CS_CONTROL_PARAM-NO_DIALOG   = 'X'.
        CS_CONTROL_PARAM-PREVIEW     = XSCREEN.
        CS_CONTROL_PARAM-GETOTF      = LS_ITCPO-TDGETOTF.
        CS_CONTROL_PARAM-LANGU       = NAST-SPRAS.
    *   CS_CONTROL_PARAM-REPLANGU1
    *   CS_CONTROL_PARAM-REPLANGU2
    *   CS_CONTROL_PARAM-REPLANGU3
    *   CS_CONTROL_PARAM-STARTPAGE
      ENDIF.
    ENDFORM.         
    after this i am calling smart form with all the required parameters.
    CALL FUNCTION gv_function
        EXPORTING
          control_parameters   = ls_control_param
          output_options       = ls_composer_param
          archive_index        = toa_dara
          archive_parameters   = arc_params
          mail_recipient       = ls_recipient
          mail_sender          = ls_sender
          user_settings        = space
        IMPORTING
            JOB_OUTPUT_INFO = ls_job_info
        TABLES
          zmm_purord_at    = zmm_purord_at
        EXCEPTIONS
          formatting_error = 1
          internal_error   = 2
          send_error       = 3
          user_canceled    = 4
          OTHERS           = 5.
    i am not getting any mail to the desired mail id.
    Any pointers to this would be highly appreciated.
    Regards,
    Sreekanth

  • How to send "SPOOL" on SAP MAil or external mail in background???

    I tried using 'SO_DOCUMENT_REPOSITORY_MANAGER' function but it failed when I run it in background. I learned that it calls a screen at the middle of the process which needs user input to go on with the process.
    Is there other way that I could send spool on SAPMail or external Mail in background??? Any suggesstions will be greatly appreciated.. thanx...

    see below sample function module, you can use in backgroud also
    FUNCTION Z_SEND_MAIL_FOR_SPOOLLIST.
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(SPOOLNUMBER) LIKE  SY-SPONO DEFAULT SY-SPONO
    *"             VALUE(MAILNAME) LIKE  SOOD1-OBJNAM DEFAULT 'NOTE'
    *"             VALUE(SUBJECT) LIKE  SOOD1-OBJDES
    *"             VALUE(RECEPIENT) LIKE  SY-UNAME OPTIONAL
    *"             VALUE(DLI) LIKE  SOOS1-DLINAM OPTIONAL
    *"       TABLES
    *"              TEXT STRUCTURE  SOLI OPTIONAL
    *"       EXCEPTIONS
    *"              ERROR
    DATA: OBJECT_HD_CHANGE LIKE SOOD1 OCCURS 0 WITH HEADER LINE,
          OBJPARA          LIKE SELC  OCCURS 0 WITH HEADER LINE,
          RECEIVERS        LIKE SOOS1 OCCURS 0 WITH HEADER LINE.
    OBJECT_HD_CHANGE-OBJLA  = SY-LANGU.
    OBJECT_HD_CHANGE-OBJNAM = MAILNAME.
    OBJECT_HD_CHANGE-OBJDES = SUBJECT.
    OBJECT_HD_CHANGE-OBJSNS = 'F'.
    OBJECT_HD_CHANGE-VMTYP  = 'T'.
    OBJECT_HD_CHANGE-SKIPS  = 'X'.
    OBJECT_HD_CHANGE-ACNAM  = 'SP01'.
    OBJECT_HD_CHANGE-OBJCP  = 'X'.
    RECEIVERS-RCDAT  = SY-DATUM.
    RECEIVERS-RCTIM  = SY-UZEIT.
    IF DLI IS INITIAL.
        RECEIVERS-RECNAM = RECEPIENT.
        RECEIVERS-RTUNAM = RECEPIENT.
    ELSE.
        RECEIVERS-RECNAM = DLI.
        RECEIVERS-ADR_NAME = DLI.
        RECEIVERS-RECESC = 'C'.
    ENDIF.
    RECEIVERS-SNDEX  = 'X'.     " Express-Mail
    APPEND RECEIVERS.
    OBJPARA-NAME = 'SPI'.
    OBJPARA-LOW  = SPOOLNUMBER.
    APPEND OBJPARA.
    CALL FUNCTION 'SO_OBJECT_SEND'
          EXPORTING
               OBJECT_HD_CHANGE           = OBJECT_HD_CHANGE
               OBJECT_TYPE                = 'RAW'
               OWNER                      = SY-UNAME
          TABLES
               OBJCONT                    = TEXT
               OBJPARA                    = OBJPARA
               RECEIVERS                  = RECEIVERS
          EXCEPTIONS
               OTHERS                     = 01.
    IF SY-SUBRC NE 0.
       RAISE ERROR.
    ENDIF.
    ENDFUNCTION.

  • Send Workitem to external mail ID and Execute?

    Hi all,
    I have requirement to send a WorkItem to Approvers External Mail ID and executes there.I have tried to send text mail to Approver's external mail id using Fm SO_NEW_DOCUMENT_SEND_API1.
    It is working fine but how to send WI to external mail id?
    Is there any way?
    Regards,
    Arpita

    Hi AC,
    there is a way out for the problem which you have where the user doesnt want to put his SAP userid and pwd and wants him to take directly to the SAP screen.
    For this you need to create a shortcut in your SAP logon pad for the transaction.
    and since you want him/her to go directly to the tcode, you need to put an entry in your sapshortcut.ini
    -pw "password"
    So what this entry does is the moment user clicks the workitem in Outlook, it would directly take him to the t-code for which you have created the shortcut, without asking him/her credentials.
    For your second issue, yes if 2 users get workitem, if any one reserves or executes the workitem, it automatically deletes from the other users SAP inbox.
    Hope it helps.
    Aditya

  • How Sapscript form can be send by mail

    Hello all,
    I want to send a Sapscript form by mail.
    I think it should first be converted to PDF form and than need to be send by mail.
    I have created a z form which is a copy of standard for medruck and also have changed the standard program SAPFM06P. So I need to add functionality in z program so that i can send the sapscript form by mail.
    Can any body let me know the complete process how can i do it?
    Thanks

    Hi,
    Just follow the below code . I am giving the code which starts from OPEN_FORM. After that one submit program is there u can see the code.
    *&      Form  display_layout
          text
    -->  p1        text
    <--  p2        text
    FORM display_layout.
      CALL FUNCTION 'OPEN_FORM'
       EXPORTING
      APPLICATION                       = 'TX'
      ARCHIVE_INDEX                     =
      ARCHIVE_PARAMS                    =
         device                            = 'PRINTER'
      DIALOG                            = 'X'
         form                              = 'YFIL_DUNN_01'
      LANGUAGE                          = SY-LANGU
       options                           = itcpo
      MAIL_SENDER                       =
      MAIL_RECIPIENT                    =
      MAIL_APPL_OBJECT                  =
      RAW_DATA_INTERFACE                = '*'
    IMPORTING
      LANGUAGE                          =
      NEW_ARCHIVE_PARAMS                =
      RESULT                            =
       EXCEPTIONS
         canceled                          = 1
         device                            = 2
         form                              = 3
         options                           = 4
         unclosed                          = 5
         mail_options                      = 6
         archive_error                     = 7
         invalid_fax_number                = 8
         more_params_needed_in_batch       = 9
         spool_error                       = 10
         OTHERS                            = 11
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      LOOP AT i_tab INTO wa_tab.
        CALL FUNCTION 'WRITE_FORM'
         EXPORTING
           element                     = '531'
      FUNCTION                       = 'SET'
      TYPE                           = 'BODY'
           window                      = 'MAIN'
    IMPORTING
       pending_lines                  = wa_tab.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'CLOSE_FORM'
       IMPORTING
         result                         = itcpp
        RDI_RESULT                     =
      TABLES
        OTFDATA                        =
         EXCEPTIONS
           unopened                       = 1
           bad_pageformat_for_print       = 2
           send_error                     = 3
           spool_error                    = 4
           OTHERS                         = 5.
      IF sy-subrc = 0.
        IF ( itcpp-userexit IS INITIAL AND
            NOT itcpp-tdspoolid IS INITIAL ).
          p_spool = itcpp-tdspoolid.
          SUBMIT yfir_mailsend_pdf_attachment WITH p_spool = p_spool
                                              WITH p_kunnr = p_kunnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " display_layout
    *&      Form  modify_duedate
          text
    -->  p1        text
    <--  p2        text
    FORM modify_duedate.
      SELECT SINGLE mat_rec_no
                    mat_rec_date FROM yfi_matno
                    INTO (v_mat_rec_no, v_mat_rec_date)
                    WHERE vbeln = wa_tab-vbeln.
      CHECK sy-subrc EQ 0.
      SELECT SINGLE zterm
                    FROM vbrk INTO  v_zterm
                    WHERE vbeln EQ wa_tab-vbeln.
      CHECK sy-subrc EQ 0.
      SELECT SINGLE zdays
                    FROM yfi_payment INTO v_zdays
                    WHERE zterm EQ v_zterm.
      IF sy-subrc EQ 0.
        wa_tab-zfbdt_due = ( v_mat_rec_date + v_zdays ).
        wa_tab-due_days = ( sy-datum - wa_tab-zfbdt_due ).
       IF wa_tab-due_days LE 0.
         wa_tab-due_days = 'N/A'.
       ENDIF.
        IF ( wa_tab-umskz = 'A' AND wa_tab-shkzg = 'H' ).
          wa_tab-zfbdt = ' '.
          wa_tab-zfbdt_due = ''.
          wa_tab-due_days = ''.
        ENDIF.
        MODIFY i_tab FROM wa_tab INDEX sy-tabix.
        CLEAR: v_mat_rec_no, v_mat_rec_date, v_zterm, v_zdays.
      ENDIF.
    ENDFORM.                    " modify_duedate
    SUBMIT PROGRAM :
    REPORT yfir_mailsend_pdf_attachment MESSAGE-ID yf.
    *& Program Name   : *
    & Author         :
    *& Creation Date  : *
    *& Program Type   :                                                   *
    *& SAP Release    : *
    *& Description    :     *
    *& Transport No   :                                                   *
    *& Transaction    :                                                   *
    *&  Send document with OTF/ALI attachment from spool to externalreci-
    *&  pient. OTF/ALI document is converted to PDF/HTML format duringthe
    *&  SAPconnect send process.
    *&  This report serves as example documentation for the function
    *&  modules SO_NEW_DOCUMENT_ATT_SEND_API1 and SO_DOCUMENT_SEND_API1.
    *&  Following this example you should be able to develop your own
    *&  report to send documents with all kinds of attachments.
    Creation of the entry for the compressed document
    *& TABLES:
    TABLES : kna1,
            adr6.
    *& INTERNAL TABLES:
    ***********PDF Declaration*******
    DATA: BEGIN OF i_spool OCCURS 0,
            rqident  LIKE tsp01-rqident,
            rqo1name LIKE tsp01-rqo1name,
            rqclient LIKE tsp01-rqclient,
          END   OF i_spool.
    *& VARIABLES :
    DATA: client LIKE tst01-dclient,
          name LIKE tst01-dname,
          objtype LIKE rststype-type,
          type LIKE rststype-type.
    DATA: spoolno LIKE tsp01-rqident,
         download TYPE c VALUE 'X', "AS CHECKBOX DEFAULT 'X',
         p_file LIKE rlgrap-filename
                         VALUE 'C:\Invoice.pdf',               "#EC NOTEXT
          otf LIKE itcoo OCCURS 100 WITH HEADER LINE,
         cancel,
          pdf LIKE tline OCCURS 100 WITH HEADER LINE,
          doctab LIKE docs OCCURS 1 WITH HEADER LINE,
          numbytes TYPE i,
          arc_idx LIKE toa_dara,
          pdfspoolid LIKE tsp01-rqident,
          jobname LIKE tbtcjob-jobname,
          jobcount LIKE tbtcjob-jobcount,
          is_otf.
    Data Declaration
    DATA: docdata    LIKE sodocchgi1,
          objpack    LIKE sopcklsti1 OCCURS  1 WITH HEADER LINE,
          objhead    LIKE solisti1   OCCURS  1 WITH HEADER LINE,
          objtxt     LIKE solisti1   OCCURS 10 WITH HEADER LINE,
          objbin     LIKE solisti1   OCCURS 10 WITH HEADER LINE,
          objhex     LIKE solix      OCCURS 10 WITH HEADER LINE,
          reclist    LIKE somlreci1  OCCURS  1 WITH HEADER LINE.
    *objpack-head_start = 1.
    *objbin = '  |  '. APPEND objbin.
    *DATA: listobject LIKE abaplist   OCCURS  1 WITH HEADER LINE.
    DATA: tab_lines  TYPE i,
          doc_size   TYPE i,
          att_type   LIKE soodk-objtp.
    objpack-head_start = 1.
    *& PARAMETERS:
    PARAMETERS : p_spool LIKE tsp01-rqident NO-DISPLAY,
                 p_kunnr LIKE kna1-kunnr NO-DISPLAY.
    *& M A I N   P R O C E S S
    *& START OF SELECTION.
    START-OF-SELECTION.
      SELECT SINGLE
      adr6~addrnumber
      adr6~smtp_addr
      FROM adr6
      INNER JOIN kna1
      ON kna1~adrnr = adr6~addrnumber
      INTO CORRESPONDING FIELDS OF adr6
      WHERE kna1~kunnr = p_kunnr.
      IF sy-subrc = 0.
    Create receiver list
        reclist-receiver = adr6-smtp_addr. "<-- customer address
        reclist-rec_type = 'U'.
        APPEND reclist.
      ENDIF.
    ***Convert Spool request to PDF
      PERFORM pdf_convert.
      docdata-obj_name  = 'MAIL_AEIW'.
      docdata-obj_descr = 'Dunning'.
      Main Text
      objtxt = 'Hi,'.
      APPEND objtxt.
      objtxt = 'Dunning'.
      APPEND objtxt.
      objtxt = 'Regards'.
      APPEND objtxt.
      Write Packing List (Main)
      DESCRIBE TABLE objtxt LINES tab_lines.
      READ     TABLE objtxt INDEX tab_lines.
      docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
      CLEAR objpack-transf_bin.
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = 'RAW'.
      APPEND objpack.
    Create Message Attachment
      Write Packing List (Attachment)
      att_type = 'PDF'.
      DESCRIBE TABLE objbin LINES tab_lines.
      READ     TABLE objbin INDEX tab_lines.
    *objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
      objpack-doc_size = tab_lines * 255.
      objpack-transf_bin = 'X'.
      objpack-head_start = 1.
      objpack-head_num   = 1.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = att_type.
      objpack-obj_name   = 'ATTACHMENT'.
      objpack-obj_descr  = 'Attached Document'.
      APPEND objpack.
    *check for not maintaining customer address
      IF reclist IS INITIAL.
        MESSAGE e000 WITH 'Please Maintain Customer e-Mail ID'.
        LEAVE LIST-PROCESSING.
      ELSE.
    Send Message
        CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
          EXPORTING
            document_data                     = docdata
             put_in_outbox                     = 'X'
        commit_work                       = 'X'     "used from rel.6.10
      IMPORTING
        SENT_TO_ALL                        =
        NEW_OBJECT_ID                     =
          TABLES
            packing_list                      = objpack
            object_header                     = objhead
            contents_bin                      = objbin
            contents_txt                      = objtxt
        CONTENTS_HEX                      = objhex
        OBJECT_PARA                        =
        OBJECT_PARB                        =
            receivers                         = 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 ID 'SO' TYPE 'S' NUMBER '023'
                  WITH docdata-obj_name.
        ELSE.
          WRITE 'Mail sent successfully'.
        ENDIF.
      ENDIF.
      WRITE: / 'End of Program'.
    *&      Form  pdf_convert
          text
    -->  p1        text
    <--  p2        text
    FORM pdf_convert.
      DATA: date1   LIKE sy-datum,
            time1   LIKE sy-uzeit,
            period1 LIKE tsp01-rqcretime.
      date1 = sy-datum.
      time1 = sy-uzeit.
      date1 = date1 - 1.
      CONCATENATE date1 time1 INTO period1.
      SELECT rqident
             rqo1name
             rqclient FROM tsp01 INTO TABLE i_spool
                            WHERE rqowner   = sy-uname AND
                                  rqclient  = sy-mandt AND
                                  rqident   = p_spool.
      IF sy-subrc <> 0.
        WRITE: / 'No Spool Request created today'(003)
                COLOR COL_NEGATIVE.
        EXIT.
      ENDIF.
      SORT i_spool DESCENDING BY rqident.
      READ TABLE i_spool INDEX 1.
      CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
             EXPORTING
                authority     = 'SP01'
                client        = i_spool-rqclient
                name          = i_spool-rqo1name
                part          = 1
             IMPORTING
              CHARCO        =
              CREATER       =
              CREDATE       =
              DELDATE       =
              MAX_CREDATE   =
              MAX_DELDATE   =
              NON_UNIQ      =
              NOOF_PARTS    =
              RECTYP        =
              SIZE          =
              STOTYP        =
                  type          = type
                  objtype       = objtype
             EXCEPTIONS
                  fb_error      = 1
                  fb_rsts_other = 2
                  no_object     = 3
                  no_permission = 4.
      CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
          EXPORTING
            src_spoolid                    = i_spool-rqident
            no_dialog                      = ' '
          DST_DEVICE                     =
          PDF_DESTINATION                =
          IMPORTING
            pdf_bytecount                  = numbytes
            pdf_spoolid                    = pdfspoolid
          OTF_PAGECOUNT                  =
            btc_jobname                    = jobname
            btc_jobcount                   = jobcount
          TABLES
            pdf                            = pdf
          EXCEPTIONS
            err_no_otf_spooljob            = 1
            err_no_spooljob                = 2
            err_no_permission              = 3
            err_conv_not_possible          = 4
            err_bad_dstdevice              = 5
            user_cancelled                 = 6
            err_spoolerror                 = 7
            err_temseerror                 = 8
            err_btcjob_open_failed         = 9
            err_btcjob_submit_failed       = 10
            err_btcjob_close_failed        = 11.
      CASE sy-subrc.
        WHEN 0.
        WHEN 1.
          WRITE: / 'Error On Spool Job'(002)
                COLOR COL_NEGATIVE.
          EXIT.
        WHEN 2.
          WRITE: / 'No Permission'(003)
                COLOR COL_NEGATIVE.
          EXIT.
        WHEN 3.
          WRITE: / 'Conversion Not Possible'(004)
                COLOR COL_NEGATIVE.
          EXIT.
        WHEN OTHERS.
          WRITE: / 'Incorrect Destination Device'(005)
                    COLOR COL_NEGATIVE.
          EXIT.
      ENDCASE.
      CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
           EXPORTING
                line_width_src              = 134
                line_width_dst              = 255
           TABLES
                content_in                  = pdf
                content_out                 = objbin
           EXCEPTIONS
                err_line_width_src_too_long = 1
                err_line_width_dst_too_long = 2
                err_conv_failed             = 3
                OTHERS                      = 4.
    ENDFORM.                    " pdf_convert

  • External Mail's Sending Via Abap Code

    <u>Hello, everyone.</u>
    I have a problem with an external mail's sending, I have to solve it very quickly.
    I'm tring to send mail to a specific address with an attachment but it doesn't work.
    Does any one has some source code that works (with file attached) ?
    Thanks in advance,
    Rebeka

    Hi rebeka,
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = 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 ID 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

  • Sending of GR & GI slips through external mail

    Hi All,
    Kindly suggest me, to achieve following client requirement.
    The requirement is to send the GR and GI slips through external mail to "Goods Recipient" for MIGO transaction.
    Many thanks,
    Venkat

    You might want to use the message type MLGR (mail at goods receipt), but
    this message type will only work with the Message transmission medium 7
    (SAPoffice) and the processing routines:
    Program     : RSNASTSO
    FORM routine: SAPOFFICE_AUFRUF
    this is, unfortunately, you will be unable to send out an external
    mail (transmission medium 5) to your vendor using the message type MLGR.
    For a message type MLGR to be outputed, it is necessary to flag in the
    Purchase Order Header the 'Goods receipt message' indicator (EKKO-WEAKT)
    and, as you can read in the F1-on-line help for this indicator:
    "Indicator: Goods receipt message
    Indicator specifying that the system is to issue an appropriate message
    to the buyer following each goods receipt in respect of this purchase
    order".
    Therefore, the system has been designed to send an internal e-mail to
    the User ID who created the purchase order (buyer). This is made via
    SAPoffice and medium 7. However, the system has not been designed to
    send an external e-mail to the vendor.
    You can also check the IMG Activity Documentation for the activity
    'Output Determination' under the path:
    SPRO
    -> Materials Management
       -> Inventory Management and Physical Inventory
          -> Output Determination
    "Output Determination
    In Inventory Management, output is text that is created at the time of
    goods movements. There are output documents such as:
    .- goods receipt/issue slips ( example, GR/GI slips, pallet slips)
    .- labels
    .- kanban cards
    .- MAIL messages which Inventory Management uses to communicate with
        other departments (purchasing or materials planning, for example).
    Note:
    In the case of a goods receipt for a purchase order, MAIL messages are
    sent to purchasing in two cases:
    .- if Purchasing has set the indicator "GR output" in the purchase
        order,
    .- if an order price quantity has been entered at the time of a goods
        receipt which lies outside the tolerances (for a warning message).
    In the case of a goods receipt of missing parts, a mail message is sent
    to the MRP controller if the missing parts check is active for the
    plant.
    The standard system contains all settings for this output. You only
    have to maintain the mail texts for the following output types:
    MLGR (GR message)
    MLMD (GR quantity variance)
    MLFH (goods receipt of missing part)".
    Therefore:
    1.- MAIL messages within Inventory Management are used to communicate
        with other departments (purchasing or materials planning, for
        example), but not to send out information to vendors.
    2.- MLGR (GR message) are sent out to the Purchasing department only
        when the indicator "GR Message" has been set in the purchase order.

  • How to send sapmails to external mail systems

    Hi,
    how to send sapmails to external mail systems....
    like if we want to mail a purchase order from SAP System to *@yahaoo.com or @.com.
    TY.

    hi manish,
    u can do it.
    chk this .
    chk this code
    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.
    *& Form f_send_mail
    text
    --> p1 text
    <-- p2 text
    FORM f_send_mail .
    *store the vendor name, vendor email id , employee name and employee
    *email id in the internal table int_crb
    Creation of the document to be sent
    CLEAR doc_chng.
    REFRESH objpack.
    REFRESH objhead.
    REFRESH reclist.
    REFRESH objtxt.
    File Name
    doc_chng-obj_name = 'SHIPMENT'.
    Mail Subject
    CONCATENATE 'Shipment Document No.' int_crb_mail-shipdocnum
    'Cleared.'
    INTO doc_chng-obj_descr SEPARATED BY ' '.
    Mail Contents
    objtxt-line = 'Hi,'.
    APPEND objtxt.
    objtxt-line = ' '.
    APPEND objtxt.
    CONCATENATE 'Shipment Document Number ' int_crb_mail-shipdocnum
    ' cleared for move.' INTO objtxt-line SEPARATED BY ' '.
    APPEND objtxt.
    objtxt-line = ' '.
    APPEND objtxt.
    CLEAR objtxt.
    objtxt-line = 'Regards '.
    APPEND objtxt.
    objtxt-line = ' '.
    APPEND objtxt.
    objtxt-line = 'SAP '.
    APPEND objtxt.
    CLEAR objtxt.
    APPEND objtxt.
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN(
    objtxt ).
    Creation of the entry for the compressed document
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'RAW'.
    APPEND objpack.
    Completing the recipient list
    target recipent
    CLEAR reclist.
    reclist-receiver = int_crb_mail-empperid. "employee email ID
    "wf_empperid.
    reclist-express = 'X'.
    reclist-rec_type = 'U'.
    APPEND reclist.
    copy recipents
    CLEAR reclist.
    reclist-receiver = int_crb_mail-smtp_addr."vendor email id
    reclist-express = 'X'.
    reclist-rec_type = 'U'.
    reclist-copy = 'X'.
    APPEND reclist.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = doc_chng
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    receivers = reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    operation_no_authorization = 4
    OTHERS = 99.
    COMMIT WORK.
    SUBMIT rsconn01
    WITH mode = 'INT'
    WITH output = ' '
    AND RETURN.
    ENDFORM. " f_send_mail
    for any clarifiaction pls mail me.
    pls reward points, if this helped u.
    regards,
    anversha.
    [email protected]

  • Send External mail with Attchment from SAP

    Hi All,
    OUR REQUIREMENT: We need to send EXTERNAL MAIL with ATTACHMENT(Excel) form SAP .
    We have developed a function module which converts the internal table data into Excel Format and sends it as an attachment to External Mail.
    ISSUE : But our issue is we are unable to open that document using GOOGLE DOCS Could any one help me how to do this.
    it was thriughing error like
    Error log is .
    ''Sorry, we are unable to generate a view of the document at this time. Please try again later.
    You can also try to download the original document by clicking here. Alternatively, you can view the plain HTML (automatically redirecting).
    Regards
    Venkat .
    Edited by: venkata pradeep on Mar 5, 2012 10:26 AM
    Edited by: venkata pradeep on Mar 5, 2012 10:28 AM

    Is the excel file recognized by MS Excel? If not, then issue is you have wrongly converted your attachment and/or your FM to create an excel file was wrongly coded or you have passed it wrongly to your mail code.
    If you consider an OOP approach in sending external mail, refer to this link:
    http://wiki.sdn.sap.com/wiki/display/Snippets/SendingmailwithattachmentusingObjectOriented+Approach

  • Sending external mail with excel attachment from SAP

    Hi All,
    I am trying to send a external mail from SAP. Mail is getting posted correctly with attachment having type excel. If attach file has more than 1 records then in mail it is coming in a single lines. it is not getting wrap.
    e.g. my attach internal table has records like LINE1
                                                                      LINE2
                                                                      LINE3
    output in attach excel file is : LINE1         LINE2          LINE3
    in attach file it should come line by line.
    source code of my function module is as follows :
    FUNCTION ZXI_SEND_MAIL_WITH_ATTACHMENT.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(SUBJECT) TYPE  SO_OBJ_DES OPTIONAL
    *"     REFERENCE(ATTACH_NAME1) TYPE  SOOD-OBJDES
    *"     REFERENCE(EXT1) TYPE  SOODK-OBJTP
    *"     REFERENCE(MAIL_ID) TYPE  ADR6-SMTP_ADDR
    *"  TABLES
    *"      IT_CONTENT TYPE  SOLI_TAB OPTIONAL
    *"      IT_ATTACH TYPE  SOLI_TAB OPTIONAL
      DATA: send_request       TYPE REF TO cl_bcs.
      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: exception_info     TYPE REF TO if_os_exception_info,
      bcs_exception      TYPE REF TO cx_document_bcs.
      DATA i_attachment_size TYPE sood-objlen.
    Creates persistent send request
      send_request = cl_bcs=>create_persistent( ).
      TRY.
    *****Create txt mail document**************************
          document = cl_document_bcs=>create_document(
                                        i_type    = 'RAW'
                                        i_text = it_content[]
                                        i_subject = subject ).
    **************Creates Attachment 1***********************
          CALL METHOD document->add_attachment
            EXPORTING
              i_attachment_type    = ext1
              i_attachment_subject = attach_name1
              i_att_content_text   = it_attach[].
    Add document to send request
          CALL METHOD send_request->set_document( document ).
    Get sender object
          sender = cl_sapuser_bcs=>create( sy-uname ).
    Add sender
          CALL METHOD send_request->set_sender
            EXPORTING
              i_sender = sender.
          recipient = cl_cam_address_bcs=>create_internet_address(
                               i_address_string = mail_id ).
          CALL METHOD send_request->add_recipient
            EXPORTING
              i_recipient  = recipient
              i_express    = 'U'
              i_copy       = ' '
              i_blind_copy = ' '
              i_no_forward = ' '.
    **********Trigger e-mails immediately****************************
          send_request->set_send_immediately( 'X' ).
          CALL METHOD send_request->send( ).
          COMMIT WORK.
        CATCH cx_document_bcs INTO bcs_exception.
      ENDTRY.
    ENDFUNCTION.
    please suggest me a solution and thanks in advance.
    Thanks&Regards,
    Sachin

    See the sample code  for sending attachment as Mail
    Mailing with Attachment by ABAP Coding  
    Refer this link:
    Mail with attachment.
    FORM send_list_to_basis .
      DATA: w_path      LIKE rlgrap OCCURS 0 WITH HEADER LINE,
            lt_index    TYPE sy-tabix,
            doc_type(3) TYPE c,
            descr       LIKE it_objpack_basis-obj_descr,
            temp_data   LIKE w_path,
            temp1       TYPE string,
            tab_lines   TYPE i,
            langu(15)   TYPE c,
            expirydate  TYPE so_obj_edt,
            L_FILE1(100).
      CONCATENATE 'C:\' sy-repid '_' sy-datum '.XLS' INTO L_FILE1.
      W_PATH-FILENAME = L_FILE1.
      APPEND w_path.
      CLEAR w_path.
      wa_doc_chng-obj_descr  = 'User List not logged on for 180 days'.
      wa_doc_chng-obj_langu  = 'E'.
      wa_doc_chng-obj_expdat = sy-datum.
      CLEAR w_subject.
      CONCATENATE 'Please find attached document with list of users'
                  'not logged on for 180 days for client' sy-mandt
                  INTO w_subject SEPARATED BY space.
      it_objtxt_basis-line = w_subject.
      APPEND it_objtxt_basis.
      CLEAR it_objtxt_basis.
      it_objtxt_basis-line = text-004.
      APPEND it_objtxt_basis.
      CLEAR it_objtxt_basis.
      CLEAR w_tab_line.
      DESCRIBE TABLE it_objtxt_basis LINES w_tab_line.
      READ TABLE it_objtxt_basis INDEX w_tab_line  INTO l_cline.
      wa_doc_chng-doc_size =
       ( w_tab_line - 1 ) * 255 + STRLEN( l_cline ).
      CLEAR it_objpack_basis-transf_bin.
      it_objpack_basis-head_start = 1.
      it_objpack_basis-head_num   = 0.
      it_objpack_basis-body_start = 1.
      it_objpack_basis-body_num   = w_tab_line.
      it_objpack_basis-doc_type   = 'RAW'.
      APPEND it_objpack_basis.
      CLEAR it_objpack_basis.
      LOOP AT w_path.
        temp1 = w_path.
        descr = w_path.
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string  = descr
            lang    = 'E'
          IMPORTING
            rstring = descr.
        CALL FUNCTION 'STRING_SPLIT'
          EXPORTING
            delimiter = '\'
            string    = descr
          IMPORTING
            head      = descr
            tail      = temp_data.
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string  = descr
            lang    = 'E'
          IMPORTING
            rstring = descr.
        CALL FUNCTION 'STRING_SPLIT'
          EXPORTING
            delimiter = '.'
            string    = descr
          IMPORTING
            head      = temp_data
            tail      = doc_type.
        CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            filename      = temp1
            filetype      = 'BIN'
            header_length = 0
            read_by_line  = 'X'
            replacement   = '#'
          TABLES
            data_tab      = it_upload.
        DESCRIBE TABLE it_upload LINES tab_lines.
        DESCRIBE TABLE it_objbin_basis LINES lt_index.
        lt_index = lt_index + 1.
        LOOP AT it_upload.
          wa_objbin_basis-line = it_upload-line.
          APPEND wa_objbin_basis TO it_objbin_basis.
          CLEAR wa_objbin_basis.
        ENDLOOP.
        it_objpack_basis-transf_bin = 'X'.
        it_objpack_basis-head_start = 0.
        it_objpack_basis-head_num   = 0.
        it_objpack_basis-body_start = lt_index.
        it_objpack_basis-body_num   = tab_lines.
        it_objpack_basis-doc_type   = doc_type.
        it_objpack_basis-obj_descr  = descr.
        it_objpack_basis-doc_size   = tab_lines * 255.
        APPEND it_objpack_basis.
        CLEAR it_objpack_basis.
      ENDLOOP.
      it_reclist_basis-receiver = '[email protected]'.
      it_reclist_basis-rec_type = 'U'.
      APPEND it_reclist_basis.
      CLEAR it_reclist_basis.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_objpack_basis
          contents_txt               = it_objtxt_basis
          contents_bin               = it_objbin_basis
          receivers                  = it_reclist_basis
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      IF sy-subrc EQ 0.
        SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
      ENDIF.
    ENDFORM.                    " send_list_to_basis
    Reward points if useful
    Regards
    Anji

Maybe you are looking for

  • How to remove calendar

    My support team Sending meeting request for group of users . Problem is who are using Ex2010 / 2013 they are getting  Meeting request like on printshot 1 : It means they are getting details for when and where option. Where on printshot2 that is corre

  • Message not working on Maverick OS X10.9.1

    I am running OS X 10.9.1 (Maverick) and cannot get Messages to work. The version I have of Message is 8.0 (4218). Can anybody help fix this?

  • Sim card of ipad air

    If I bought ipad air wifi with cellular version, can I insert my sim card of iphone5?

  • SQLite micro-optimization based on LiveDocs unclear

    This article on Livedocs says you should add the database name in front of tables. http://help.adobe.com/en_US/AIR/1.5/devappsflex/WS5b3ccc516d4fbf351e63e3d118666ade46-7d47. html My question is, should I do that everywhere where a table name appears

  • Cannot update mesa

    As I said in the object, I can't update mesa. I'm using kde x86_64. To update the system I modified pacman.conf to ignore the update of mesa, then downloaded it from my mirror and installed manually with pacman -U. At the end, a good pacman -Syu work