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

Similar Messages

  • Function module to send mail from SAP

    Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.

    Hi shafiq,
    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.

  • Function module to send mail????

    Hi,
    which function module can we use to send mail in ABAP online program , i dont want to attach any file, just i want to notify the users by writing few lines in the email body. can u help me out in this issue..
    Thanks & Regards,
    Harsha Ramaiah

    Hello,
    Check this sample report.
    REPORT ZV_SEND_MAIL .
    TABLES: EKKO.
    PARAMETERS: P_EMAIL   TYPE SOMLRECI1-RECEIVER
    TYPES: BEGIN OF T_EKPO,
      EBELN TYPE EKPO-EBELN,
      EBELP TYPE EKPO-EBELP,
      AEDAT TYPE EKPO-AEDAT,
      MATNR TYPE EKPO-MATNR,
      MENGE TYPE EKPO-MENGE,
    END OF T_EKPO.
    DATA: IT_EKPO TYPE STANDARD TABLE OF T_EKPO INITIAL SIZE 0,
          WA_EKPO TYPE T_EKPO.
    TYPES: BEGIN OF T_CHAREKPO,
      EBELN(10) TYPE C,
      EBELP(5)  TYPE C,
      AEDAT(8)  TYPE C,
      MATNR(18) TYPE C,
      MENGE(16)," LIKE EKPO-MENGE,
    END OF T_CHAREKPO.
    DATA: WA_CHAREKPO TYPE T_CHAREKPO.
    DATA:   IT_MESSAGE TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   IT_ATTACH TYPE STANDARD TABLE OF SOLISTI1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   T_PACKING_LIST LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
            T_CONTENTS LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
            T_RECEIVERS LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
            T_ATTACHMENT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
            T_OBJECT_HEADER LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
            W_CNT TYPE I,
            W_SENT_ALL(1) TYPE C,
            W_DOC_DATA LIKE SODOCCHGI1,
            GD_ERROR    TYPE SY-SUBRC,
            GD_RECIEVER TYPE SY-SUBRC.
    *START_OF_SELECTION
    START-OF-SELECTION.
    *   Retrieve sample data from table ekpo
      PERFORM DATA_RETRIEVAL.
    *   Populate table with detaisl to be entered into .xls file
      PERFORM BUILD_XLS_DATA_TABLE.
    *END-OF-SELECTION
    END-OF-SELECTION.
    * Populate message body text
      PERFORM POPULATE_EMAIL_MESSAGE_BODY.
    * Send file by email as .xls speadsheet
      PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
                                   TABLES IT_MESSAGE
                                          IT_ATTACH
                                    USING P_EMAIL
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 CHANGING GD_ERROR
                                          GD_RECIEVER.
    *   Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM DATA_RETRIEVAL.
      SELECT EBELN EBELP AEDAT MATNR MENGE
    *   UP TO 10 ROWS
        FROM EKPO
        INTO CORRESPONDING FIELDS OF TABLE IT_EKPO.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
    *       Build data table for .xls document
    FORM BUILD_XLS_DATA_TABLE.
      CONSTANTS: CON_CRET TYPE X VALUE '0D',  "OK for non Unicode
                 CON_TAB TYPE X VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    *    con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' 'MENGE'
             INTO IT_ATTACH SEPARATED BY CON_TAB.
      CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
      APPEND  IT_ATTACH.
      LOOP AT IT_EKPO INTO WA_CHAREKPO.
        CONCATENATE WA_CHAREKPO-EBELN WA_CHAREKPO-EBELP
                    WA_CHAREKPO-AEDAT WA_CHAREKPO-MATNR
                    WA_CHAREKPO-MENGE
               INTO IT_ATTACH SEPARATED BY CON_TAB.
        CONCATENATE CON_CRET IT_ATTACH  INTO IT_ATTACH.
        APPEND  IT_ATTACH.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
    *       Send email
    FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
                                              PIT_ATTACH
                                        USING P_EMAIL
                                              P_MTITLE
                                              P_FORMAT
                                              P_FILENAME
                                              P_ATTDESCRIPTION
                                              P_SENDER_ADDRESS
                                              P_SENDER_ADDRES_TYPE
                                     CHANGING P_ERROR
                                              P_RECIEVER.
      DATA: LD_ERROR    TYPE SY-SUBRC,
            LD_RECIEVER TYPE SY-SUBRC,
            LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
            LD_EMAIL LIKE  SOMLRECI1-RECEIVER,
            LD_FORMAT TYPE  SO_OBJ_TP ,
            LD_ATTDESCRIPTION TYPE  SO_OBJ_NAM ,
            LD_ATTFILENAME TYPE  SO_OBJ_DES ,
            LD_SENDER_ADDRESS LIKE  SOEXTRECI1-RECEIVER,
            LD_SENDER_ADDRESS_TYPE LIKE  SOEXTRECI1-ADR_TYP,
            LD_RECEIVER LIKE  SY-SUBRC.
      LD_EMAIL   = P_EMAIL.
      LD_MTITLE = P_MTITLE.
      LD_FORMAT              = P_FORMAT.
      LD_ATTDESCRIPTION      = P_ATTDESCRIPTION.
      LD_ATTFILENAME         = P_FILENAME.
      LD_SENDER_ADDRESS      = P_SENDER_ADDRESS.
      LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
    * Fill the document data.
      W_DOC_DATA-DOC_SIZE = 1.
    * Populate the subject/generic message attributes
      W_DOC_DATA-OBJ_LANGU = SY-LANGU.
      W_DOC_DATA-OBJ_NAME  = 'SAPRPT'.
      W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
      W_DOC_DATA-SENSITIVTY = 'F'.
    * Fill the document data and get size of attachment
      CLEAR W_DOC_DATA.
      READ TABLE IT_ATTACH INDEX W_CNT.
      W_DOC_DATA-DOC_SIZE =
         ( W_CNT - 1 ) * 255 + STRLEN( IT_ATTACH ).
      W_DOC_DATA-OBJ_LANGU  = SY-LANGU.
      W_DOC_DATA-OBJ_NAME   = 'SAPRPT'.
      W_DOC_DATA-OBJ_DESCR  = LD_MTITLE.
      W_DOC_DATA-SENSITIVTY = 'F'.
      CLEAR T_ATTACHMENT.
      REFRESH T_ATTACHMENT.
      T_ATTACHMENT[] = PIT_ATTACH[].
    * Describe the body of the message
      CLEAR T_PACKING_LIST.
      REFRESH T_PACKING_LIST.
      T_PACKING_LIST-TRANSF_BIN = SPACE.
      T_PACKING_LIST-HEAD_START = 1.
      T_PACKING_LIST-HEAD_NUM = 0.
      T_PACKING_LIST-BODY_START = 1.
      DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
      T_PACKING_LIST-DOC_TYPE = 'RAW'.
      APPEND T_PACKING_LIST.
    * Create attachment notification
      T_PACKING_LIST-TRANSF_BIN = 'X'.
      T_PACKING_LIST-HEAD_START = 1.
      T_PACKING_LIST-HEAD_NUM   = 1.
      T_PACKING_LIST-BODY_START = 1.
      DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
      T_PACKING_LIST-DOC_TYPE   =  LD_FORMAT.
      T_PACKING_LIST-OBJ_DESCR  =  LD_ATTDESCRIPTION.
      T_PACKING_LIST-OBJ_NAME   =  LD_ATTFILENAME.
      T_PACKING_LIST-DOC_SIZE   =  T_PACKING_LIST-BODY_NUM * 255.
      APPEND T_PACKING_LIST.
    * Add the recipients email address
      CLEAR T_RECEIVERS.
      REFRESH T_RECEIVERS.
      T_RECEIVERS-RECEIVER = LD_EMAIL.
      T_RECEIVERS-REC_TYPE = 'U'.
      T_RECEIVERS-COM_TYPE = 'INT'.
      T_RECEIVERS-NOTIF_DEL = 'X'.
      T_RECEIVERS-NOTIF_NDEL = 'X'.
      APPEND T_RECEIVERS.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = W_DOC_DATA
                PUT_IN_OUTBOX              = 'X'
                SENDER_ADDRESS             = LD_SENDER_ADDRESS
                SENDER_ADDRESS_TYPE        = LD_SENDER_ADDRESS_TYPE
                COMMIT_WORK                = 'X'
           IMPORTING
                SENT_TO_ALL                = W_SENT_ALL
           TABLES
                PACKING_LIST               = T_PACKING_LIST
                CONTENTS_BIN               = T_ATTACHMENT
                CONTENTS_TXT               = IT_MESSAGE
                RECEIVERS                  = T_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.
    * Populate zerror return code
      LD_ERROR = SY-SUBRC.
    * Populate zreceiver return code
      LOOP AT T_RECEIVERS.
        LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
    *       Instructs mail send program for SAPCONNECT to send email.
    FORM INITIATE_MAIL_EXECUTE_PROGRAM.
      WAIT UP TO 2 SECONDS.
      SUBMIT RSCONN01 WITH MODE = 'INT'
                    WITH OUTPUT = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
    *        Populate message body text
    FORM POPULATE_EMAIL_MESSAGE_BODY.
      REFRESH IT_MESSAGE.
      IT_MESSAGE = 'Please find attached a list test ekpo records'.
      APPEND IT_MESSAGE.
    ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY
    Cheers,
    Vasanth

  • Function Module For Sending Mail

    Hi Experts,
    Is there any function module to send a mail from the ABAP program.
    My requirement is to run a report and send the content of the an Internal table as mail.
    Thanks in Advance

    hI,
      Here is the example program
    *& Report ZSENDEMAIL *
    *& Example of sending external email via SAPCONNECT *
    REPORT zsendemail .
    PARAMETERS: psubject(40) type c default 'Hello',
    p_email(40) type c default '[email protected]' .
    data: it_packing_list like sopcklsti1 occurs 0 with header line,
    it_contents like solisti1 occurs 0 with header line,
    it_receivers like somlreci1 occurs 0 with header line,
    it_attachment like solisti1 occurs 0 with header line,
    gd_cnt type i,
    gd_sent_all(1) type c,
    gd_doc_data like sodocchgi1,
    gd_error type sy-subrc.
    data: it_message type standard table of SOLISTI1 initial size 0
    with header line.
    *START-OF-SELECTION.
    START-OF-SELECTION.
    Perform populate_message_table.
    *Send email message, although is not sent from SAP until mail send
    *program has been executed(rsconn01)
    PERFORM send_email_message.
    *Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form POPULATE_MESSAGE_TABLE
    Adds text to email text table
    form populate_message_table.
    Append 'Email line 1' to it_message.
    Append 'Email line 2' to it_message.
    Append 'Email line 3' to it_message.
    Append 'Email line 4' to it_message.
    endform. " POPULATE_MESSAGE_TABLE
    *& Form SEND_EMAIL_MESSAGE
    Send email message
    form send_email_message.
    Fill the document data.
    gd_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
    gd_doc_data-obj_langu = sy-langu.
    gd_doc_data-obj_name = 'SAPRPT'.
    gd_doc_data-obj_descr = psubject.
    gd_doc_data-sensitivty = 'F'.
    Describe the body of the message
    clear it_packing_list.
    refresh it_packing_list.
    it_packing_list-transf_bin = space.
    it_packing_list-head_start = 1.
    it_packing_list-head_num = 0.
    it_packing_list-body_start = 1.
    describe table it_message lines it_packing_list-body_num.
    it_packing_list-doc_type = 'RAW'.
    append it_packing_list.
    Add the recipients email address
    clear it_receivers.
    refresh it_receivers.
    it_receivers-receiver = p_email.
    it_receivers-rec_type = 'U'.
    it_receivers-com_type = 'INT'.
    it_receivers-notif_del = 'X'.
    it_receivers-notif_ndel = 'X'.
    append it_receivers.
    Call the FM to post the message to SAPMAIL
    call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    exporting
    document_data = gd_doc_data
    put_in_outbox = 'X'
    importing
    sent_to_all = gd_sent_all
    tables
    packing_list = it_packing_list
    contents_txt = it_message
    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.
    Store function module return code
    gd_error = sy-subrc.
    Get it_receivers return code
    loop at it_receivers.
    endloop.
    endform. " SEND_EMAIL_MESSAGE
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
    wait up to 2 seconds.
    if gd_error eq 0.
    submit rsconn01 with mode = 'INT'
    with output = 'X'
    and return.
    endif.
    endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    Regards

  • 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

    Hi all,
    do you know if i can send email from ABAP, i specify that i don't have WAS. I understand that i must install SAPConnect and SMTP plug-in but in my case will that function ? 
    Regards,

    Hi
    See following  routine it will send you data as attachment.
    FORM send_mail.
      it_doc_chng-obj_name  = text-016.
      it_doc_chng-obj_descr = text-016.
      DESCRIBE TABLE it_objtxt LINES g_lines.
      READ TABLE it_objtxt INDEX g_lines.
      it_objpack-doc_size = ( g_lines - 1 ) * 255 + STRLEN( it_objtxt ).
      it_objpack-doc_type   = 'RAW'.
      APPEND it_objpack.
      it_objpack-head_start = 1.
      it_objpack-head_num   = 0.
      it_objpack-body_start = 1.
      it_objpack-transf_bin = 'X'.
      it_objpack-body_num   = g_lines.
      it_objpack-doc_type   = 'RAW'.
      it_objpack-obj_name   = 'ATTACHMENT'.
      it_objpack-obj_descr  = g_file.
      APPEND it_objpack.
    completing the recipient list
      SORT it_vmail.
      DELETE ADJACENT DUPLICATES FROM it_vmail.
      IF l_client NE 'P'.
        it_reclist-receiver = p_email.
        it_reclist-express =  'X'.
        it_reclist-rec_type = 'U'.
        APPEND it_reclist.
      ELSE.
        LOOP AT it_vmail.
          it_reclist-receiver = it_vmail-smtp_addr.
          it_reclist-express =  'X'.
          it_reclist-rec_type = 'U'.
          APPEND it_reclist.
        ENDLOOP.
      ENDIF.
      it_rec_mail[] = it_reclist[].
      IF NOT p_copy IS INITIAL.
        it_reclist-receiver = p_copy.
        it_reclist-express =  'X'.
        it_reclist-copy =  'X'.
        it_reclist-rec_type = 'U'.
        APPEND it_reclist.
      ENDIF.
      CLEAR it_download[].
      it_download[] = it_objtxt[].
    **********Sending the mail with attachment*****************
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_MAPI'
        EXPORTING
          document_data              = it_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_objpack
          contents_bin               = it_objtxt
          contents_txt               = it_objtxt
          receivers                  = it_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      CASE sy-subrc.
        WHEN 0.
          IF p_update = 'X'.
            PERFORM reference_update.
          ENDIF.
         PERFORM down_load.
          WRITE:/01 text-019.
          SKIP.
          LOOP AT it_rec_mail.
            FORMAT COLOR 5 INTENSIFIED OFF.
            WRITE:/01 text-010,20 it_rec_mail-receiver.
          ENDLOOP.
          ULINE.
        WHEN 1.
          WRITE: / text-012.
        WHEN 2.
          WRITE: / text-013.
        WHEN 4.
          WRITE: / text-014.
        WHEN OTHERS.
          WRITE: / text-015.
      ENDCASE.
      REFRESH:it_objpack,
              it_objtxt,
              it_reclist,
              it_rec_mail.
      CLEAR:it_objpack,
            it_objtxt,
            it_reclist,
            g_lines,
            it_rec_mail.
    ENDFORM.                    " send_mail
    Regards
    Suresh Babu Karanam

  • Garbage in mail body when sending mail from abap code

    Hi abapers,
    i am sending mail from my program and when the data reaches in mailbox it is as follows.
    佐呓义⁇䅄䕔䌉乏啓䕍⁒低䌉乏啓䕍⁒䅎䕍䤉⁃䥔䭃⁔低म䍉吠䍉䕋⁔䕄䍓䤉⁃䥔䭃呅匠䅔啔॓
    which is not proper.
    I'm attaching the following part of code which i have used.Please let me know if i've made any mistake over here.
    DOCDATA-OBJ_LANGU = SY-LANGU.
      DOCDATA-OBJ_NAME = 'Mail_Excel_File'.
      DOCDATA-OBJ_DESCR = 'Closed Customer Complaints'.      
      DOCDATA-SENSITIVTY = 'F'.
      OBJTXT =
      'Attached compensation request is pending for your approval as on '.
      APPEND OBJTXT. CLEAR OBJTXT.
      OBJTXT =
      'today. Please find the attached Field Investigation Report.'.
      APPEND OBJTXT. CLEAR OBJTXT.
      OBJTXT =
      'This is auto generated mail.Please do not reply to this mail.'.
      APPEND OBJTXT. CLEAR OBJTXT.
      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-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
      DESCRIBE TABLE I_CONTENTS_HEX LINES TAB_LINES.
    *  OBJPACK-DOC_SIZE = TAB_LINES * 255  + STRLEN( OBJTXT ).
      OBJPACK-DOC_SIZE = TAB_LINES * 255  .
      OBJPACK-TRANSF_BIN = 'X'.
    *  OBJPACK-TRANSF_BIN = SPACE.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'XLS'.
    * DOCDATA-OBJ_NAME = 'Excel_File_Attachment1'.
    *  OBJPACK-OBJ_DESCR = FILE_NAME.
      OBJPACK-OBJ_DESCR = P_FILE.
      APPEND OBJPACK.
      RECLIST-RECEIVER = RECIEVER.
      RECLIST-REC_TYPE = 'U'.
      RECLIST-EXPRESS = 'X'.
      APPEND RECLIST.
    * FM called for sending the mail to the intended recipients
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA = DOCDATA
          PUT_IN_OUTBOX = 'X'
          COMMIT_WORK   = 'X'
        TABLES
          PACKING_LIST  = OBJPACK
          CONTENTS_HEX  = I_CONTENTS_HEX
          CONTENTS_TXT  = OBJTXT
          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.
    what will be the problem..
    please help out.
    Regards,
    Navin
    Edited by: navin.c on Jul 10, 2009 8:08 AM

    Hi Krishna,
    I have attachment properly coming the problem is body of mail its is coming in some  unknown language
    佐呓义⁇䅄䕔䌉乏啓䕍⁒低䌉乏啓䕍⁒䅎䕍䤉⁃䥔䭃⁔低म䍉吠䍉䕋⁔䕄䍓䤉⁃䥔䭃呅匠䅔啔॓剐䑏䌠䵏⁐低म剐䌠䵏⁐呓呁单䌉䵏⹐删充低म䅌呓䌠䅈䝎䑅䄠॔剐䑏䍕⁔䕄䅔䱉॓䡓䑁⁅䅎䕍匉䅈䕄䌠䑏ॅ䅂䕓丠䵁ॅ䅂䕓䌠䑏ॅ䅂䍔⁈啎䉍剅䴉乁䙕䝃䐠呁ॅ䅓偍䕌䄠䅖䱉䉁䱉呉ख़䉏䕓噒
    what may be the problem?
    I have used the same logic . im attaching my part of code for your reference .
    DOCDATA-OBJ_LANGU = SY-LANGU.
      DOCDATA-OBJ_NAME = 'Mail_Excel_File'.
      DOCDATA-OBJ_DESCR = 'Closed Customer Complaints'.         "nsc070709+
      DOCDATA-SENSITIVTY = 'F'.
    * Describe the body of the message
    *********new additon of mail content
    * CONCATENATE  'Dear'  L_FIRSTNAME ','
    *  INTO OBJTXT SEPARATED BY SPACE.
    *  APPEND OBJTXT. CLEAR OBJTXT.
      OBJTXT =
      'Attached compensation request is pending for your approval as on '.
      APPEND OBJTXT. CLEAR OBJTXT.
      OBJTXT =
      'today. Please find the attached Field Investigation Report.'.
      APPEND OBJTXT. CLEAR OBJTXT.
      OBJTXT =
      'This is auto generated mail.Please do not reply to this mail.'.
      APPEND OBJTXT. CLEAR OBJTXT.
      DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      READ     TABLE OBJTXT INDEX TAB_LINES.
      DOCDATA-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    *  OBJTXT = 'Attached is the FIR PENDING CASES'.
    *  APPEND OBJTXT.
    *  DESCRIBE TABLE OBJTXT LINES TAB_LINES.
      CLEAR OBJPACK-TRANSF_BIN.
      OBJPACK-TRANSF_BIN = 'X'.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 0.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'RAW'.
      APPEND OBJPACK.
      DESCRIBE TABLE I_CONTENTS_HEX LINES TAB_LINES.
    *  OBJPACK-DOC_SIZE = TAB_LINES * 255  + STRLEN( OBJTXT ).
      OBJPACK-DOC_SIZE = TAB_LINES * 255  .
      OBJPACK-TRANSF_BIN = 'X'.
    *  OBJPACK-TRANSF_BIN = SPACE.
      OBJPACK-HEAD_START = 1.
      OBJPACK-HEAD_NUM = 1.
      OBJPACK-BODY_START = 1.
      OBJPACK-BODY_NUM = TAB_LINES.
      OBJPACK-DOC_TYPE = 'XLS'.
    * DOCDATA-OBJ_NAME = 'Excel_File_Attachment1'.
    *  OBJPACK-OBJ_DESCR = FILE_NAME.
      OBJPACK-OBJ_DESCR = P_FILE.
      APPEND OBJPACK.
      RECLIST-RECEIVER = RECIEVER.
      RECLIST-REC_TYPE = 'U'.
      RECLIST-EXPRESS = 'X'.
      APPEND RECLIST.
    * FM called for sending the mail to the intended recipients
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA              = DOCDATA
          PUT_IN_OUTBOX              = 'X'
          COMMIT_WORK                = 'X'
        TABLES
          PACKING_LIST               = OBJPACK
          CONTENTS_HEX               = I_CONTENTS_HEX
          CONTENTS_TXT               = OBJTXT
          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.
      COMMIT WORK.
    Can anybody help me out on this issue.
    Its somewhat on priority.
    Edited by: navin.c on Jul 10, 2009 12:58 PM

  • 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 mail from ABAP

    Hi Guys,
    I know there has been several post about this but i can get it to work.
    I have taken the example from function module.
    The sending of an express document to an internal user work.
    But as soon as i use receiver type U i dont get anything send.
    In the end i get
    &ADU00100000094 : succesfully sent
    RASS            : succesfully sent
    This means that the [email protected] has been deleted an it is only showing the id.
    Here is my code.
    REPORT  ZMON_SEND_MAIL3                         .
    DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
    DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: ENTRIES LIKE SY-TABIX.
    DATA: NAME(15).
    * Fill the document
    DOC_CHNG-OBJ_NAME = 'URGENT... Not'.
    DOC_CHNG-OBJ_DESCR = 'Read at once !'.
    DOC_CHNG-SENSITIVTY = ''.
    OBJCONT = 'Hey guys, time for lunch !!!'.
    APPEND OBJCONT.
    OBJCONT = 'Lets get going !'.
    APPEND OBJCONT.
    DESCRIBE TABLE OBJCONT LINES ENTRIES.
    READ TABLE OBJCONT INDEX ENTRIES.
    DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
    * Fill the receiver list
    CLEAR RECLIST.
    RECLIST-RECEIVER = sy-uname.  " replace with <login name>
    RECLIST-REC_TYPE = 'B'.
    RECLIST-EXPRESS = 'X'.
    APPEND RECLIST.
    CLEAR RECLIST.
    RECLIST-RECEIVER = '[email protected]'.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    * Send the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
         EXPORTING
              DOCUMENT_TYPE  = 'RAW'
              DOCUMENT_DATA  = DOC_CHNG
              PUT_IN_OUTBOX  = 'X'
         TABLES
              OBJECT_CONTENT = OBJCONT
              RECEIVERS      = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS         = 1
              DOCUMENT_NOT_SENT          = 2
              OPERATION_NO_AUTHORIZATION = 4
              OTHERS                     = 99.
        CASE SY-SUBRC.
          WHEN 0.
            LOOP AT RECLIST.
              IF RECLIST-RECEIVER = SPACE.
                NAME = RECLIST-REC_ID.
              ELSE.
                NAME = RECLIST-RECEIVER.
              ENDIF.
              IF RECLIST-RETRN_CODE = 0.
                WRITE: / NAME, ': succesfully sent'.
              ELSE.
                WRITE: / NAME, ': error occured'.
              ENDIF.
            ENDLOOP.
          WHEN 1.
            WRITE: / 'Too many receivers specified !'.
          WHEN 2.
            WRITE: / 'No receiver got the document !'.
          WHEN 4.
            WRITE: / 'Missing send authority !'.
          WHEN OTHERS.
            WRITE: / 'Unexpected error occurred !'.
        ENDCASE.
    I have test through the work place that I am able to send email out of the house.
    So the SMTP server is working.
    Any help is appreciated.

    Hi,
    Try this way
    REPORT  ZMON_SEND_MAIL3                         .
    DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
    DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: ENTRIES LIKE SY-TABIX.
    DATA: NAME(15).
    * Fill the document
    DOC_CHNG-OBJ_NAME = 'URGENT... Not'.
    DOC_CHNG-OBJ_DESCR = 'Read at once !'.
    DOC_CHNG-SENSITIVTY = ''.
    OBJCONT = 'Hey guys, time for lunch !!!'.
    APPEND OBJCONT.
    OBJCONT = 'Lets get going !'.
    APPEND OBJCONT.
    DESCRIBE TABLE OBJCONT LINES ENTRIES.
    READ TABLE OBJCONT INDEX ENTRIES.
    DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
    * Fill the receiver list
    CLEAR RECLIST.
    RECLIST-RECEIVER = sy-uname.  " replace with <login name>
    RECLIST-REC_TYPE = 'B'.
    RECLIST-EXPRESS = 'X'.
    APPEND RECLIST.
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
         EXPORTING
              DOCUMENT_TYPE  = 'RAW'
              DOCUMENT_DATA  = DOC_CHNG
              PUT_IN_OUTBOX  = 'X'
         TABLES
              OBJECT_CONTENT = OBJCONT
              RECEIVERS      = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS         = 1
              DOCUMENT_NOT_SENT          = 2
              OPERATION_NO_AUTHORIZATION = 4
              OTHERS                     = 99.
    CLEAR RECLIST. REFRESH RECLIST.
    RECLIST-RECEIVER = '[email protected]'.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    * Send the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
         EXPORTING
              DOCUMENT_TYPE  = 'RAW'
              DOCUMENT_DATA  = DOC_CHNG
              PUT_IN_OUTBOX  = 'X'
         TABLES
              OBJECT_CONTENT = OBJCONT
              RECEIVERS      = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS         = 1
              DOCUMENT_NOT_SENT          = 2
              OPERATION_NO_AUTHORIZATION = 4
              OTHERS                     = 99.
    COMMIT WORK.
    aRs

  • Function module to send mails to outlook

    Hi All,
    Can you let me know if there is an FM to send mails to the OUTLOOK. Also let me know what parameters need to be passed to the FM.
    I need to send mails to the individual and also to the user group.
    Regards
    Shiva

    HI Check the usage of the FM..
    DATA: ls_docudata LIKE sodocchgi1,
          lt_packlist LIKE sopcklsti1 OCCURS 0,
          ls_packlist LIKE LINE OF lt_packlist,
          lt_text     LIKE solisti1 OCCURS 0,
          ls_text     LIKE LINE OF lt_text,
          l_sender    LIKE soextreci1-receiver,
          l_tab_lines LIKE sy-tabix.
    DATA: lt_receivers LIKE somlreci1 OCCURS 0,
          ls_receivers LIKE LINE OF lt_receivers.
    Mail properties
    ls_docudata-obj_descr  = 'Achtung m&#58511;licher Datenschiefstand'(m01).
    ls_docudata-obj_langu  = sy-langu.
    ls_docudata-sensitivty = 'F'.
    ls_docudata-no_change  = ' '.
    ls_docudata-obj_prio   = '1'.
    ls_docudata-proc_type  = 'F'.
    ls_docudata-proc_name  = 'RKE_START_ERROR_KF631'.
    ls_docudata-free_del   = 'X'.
    Sender
    l_sender = sy-uname.
    Receiver
    ls_receivers-receiver = sy-uname.
    ls_receivers-rec_type  = 'B'.
    ls_receivers-express  = 'X'.
    APPEND ls_receivers TO lt_receivers.
    Text
    ls_text = text-m02. " F&#12539; weitere Informationen w&#33255;len ...
    APPEND ls_text TO lt_text.
    DESCRIBE TABLE lt_text LINES l_tab_lines.
    Document properties
    ls_packlist-body_start = 1.
    ls_packlist-body_num = l_tab_lines.
    ls_packlist-doc_type = 'RAW'.
    APPEND ls_packlist TO lt_packlist.
    Send mail
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
         EXPORTING
              document_data              = ls_docudata
              sender_address             = l_sender
              sender_address_type        = 'B'
         TABLES
              packing_list               = lt_packlist
              contents_txt               = lt_text
              receivers                  = lt_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.
    Praveen.
    Hope it Helps .

  • Send mail from SAP system to another SAP system

    Hello Xperts
    I need to send a mail from one SAP box (ECC) to another SAP box (SRM,CRM, EP etc). I know how to send mail from SAP to external address but unable to find the parameters in this case. Kindly help.
    thkx
    Prabhu
    PS: Kindly DONOT post on "How to send mail from SAP" as my questions is all abt how to send mail from one sap system to another sap system

    Hi
    To send mail Internally check this sample code it works fine this code was developed by me
    *& Report  ZMATURITYREPORT                                             *
    *&   Title - Maturity   report                                         *
    *&           ABAP/4 Consultant                                         *
    *& Name- Pavan Praveen Valluri Created on 26/07/2007                   *
    *& Module - FI                                                         *
    REPORT  ZMATURITYREPORT.
    tables: bseg.
    * SELECTION SCREEN---------------------------------------------------  *
    parameters: p_email type somlreci1-receiver default
    '@gujaratpetro.com'.
    * Data: p_email(25) type c value '[email protected]'.
    * END OF SELECTION SCREEN -------------------------------------------  *
    *----------DATA DECLARATION--------------------------------------------*
    data: it_message type standard table of solisti1 initial size 0
    with header line.
    data: it_message1 type standard table of solisti1 initial size 0
    with header line.
    data: it_message2(10) type N.
    data: it_message3 type standard table of solisti1 initial size 0
    with header line.
    data: it_message4 type standard table of solisti1 initial size 0
    with header line.
    data: it_attach type standard table of solisti1 initial size 0
    with header line.
    data: text(150).
    data: t_packing_list like sopcklsti1 occurs 0 with header line,
          t_contents like solisti1 occurs 0 with header line,
          t_receivers like somlreci1 occurs 0 with header line,
          t_attachment like solisti1 occurs 0 with header line,
          t_object_header like solisti1 occurs 0 with header line,
          w_cnt type i,
          w_sent_all(1) type c,
          w_doc_data like sodocchgi1,
          gd_error type sy-subrc,
          gd_reciever type sy-subrc.
    start-of-selection.
    data: lv_date type sy-datum.
    data: lv_date1 type sy-datum.
    data: lv_formatdate(10) type c.
    data: lv_formatdate1(10) type c.
    data: var1(4) type c,
    var2(2) type c,
    var3(2) type c.
    data: begin of int_bseg occurs 0,
        BELNR LIKE BSEG-BELNR,
        ZUONR LIKE BSEG-ZUONR,
        GJAHR LIKE BSEG-GJAHR,
        DMBTR LIKE BSEG-DMBTR,
        HKONT LIKE BSEG-HKONT,
    end of int_bseg.
    data: begin of int_SKAT occurs 0,
        TXT50 LIKE SKAT-TXT50,
        SAKNR LIKE SKAT-SAKNR,
        KTOPL LIKE SKAT-KTOPL,
    end of int_SKAT.
    data: begin of int_bkpf occurs 0,
          BELNR LIKE BKPF-BELNR,
          BUKRS LIKE BKPF-BUKRS,
          GJAHR LIKE BKPF-GJAHR,
          BUDAT  LIKE BKPF-BUDAT,
    end of int_BKPF.
    data: 2days_out type sy-datum.
    2days_out = sy-datum + 2.
    data: var4(4) type c,
    var5(2) type c,
    var6(2) type c.
    *-------- END OF DATA DECLARATION--------------------------------------*
    *--- CONCATENATING AND ARRANGING DATE ---------------------------------*
    lv_date = 2days_out.
    var1 = lv_date+(4).
    var2 = lv_date+4(2).
    var3 = lv_date+6(2).
    concatenate var3 var2 var1 into lv_formatdate separated by '.'.
    *--- END OF CONCATENATING AND ARRANGING DATE  -------------------------*
    *-------------------------SELECTION FOR BSEG---------------------------*
    select zuonr belnr bukrs GJAHR DMBTR HKONT from bseg into
    corresponding fields of  table int_bseg
    where bukrs = 'company name' and
          ZUONR = lv_formatdate.
    *--------------END OF SSELECTION FOR BSEG---------------------------   *
    *-------------------------SELECTION FOR BKPF---------------------------*
    select  BUDAT BUKRS BELNR GJAHR  from BKPF into
    corresponding fields of table int_BKPF
    where bukrs = 'company name'.
    append int_BKPF.
    *------------------END OF SELECTION FOR BKPF---------------------------*
    *-------------------------SELECTION FOR SKAT---------------------------*
    select SAKNR TXT50 from SKAT into
    corresponding fields of  table int_SKAT
    where KTOPL = 'company name'.
    *and      SAKNR = INT_BSEG-HKONT.
    APPEND INT_SKAT.
    *--------------END OF SSELECTION FOR SKAT---------------------------   *
    *-----------------POPULATING EMAIL SUBJECT ----------------------------*
    perform populate_email_message_body.
      perform send_file_as_email_attachment
      tables it_message
      it_attach
      using p_email
      'Maturity after 2 days'
      'XLS'
      'filename'
      changing gd_error
      gd_reciever.
    * Instructs mail send program for SAPCONNECT to send email(rsconn01)
      perform initiate_mail_execute_program.
    *endif.
    end-of-selection.
    *------------END OF POPULATING EMAIL SUBJECT --------------------------*
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    * Send email
    form send_file_as_email_attachment tables pit_message
    pit_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
      data: ld_error type sy-subrc,
      ld_reciever type sy-subrc,
      ld_mtitle like sodocchgi1-obj_descr,
      ld_email like somlreci1-receiver,
      ld_format type so_obj_tp ,
      ld_attdescription type so_obj_nam ,
      ld_attfilename type so_obj_des ,
      ld_sender_address like soextreci1-receiver,
      ld_sender_address_type like soextreci1-adr_typ,
      ld_receiver like sy-subrc.
      ld_email = p_email.
      ld_mtitle = p_mtitle.
      ld_format = p_format.
      ld_attdescription = p_attdescription.
      ld_attfilename = p_filename.
      ld_sender_address = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    * Fill the document data.
      w_doc_data-doc_size = 1.
    * Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    ** Fill the document data and get size of attachment
      clear w_doc_data.
      read table it_attach index w_cnt.
      w_doc_data-doc_size =
      ( w_cnt - 1 ) * 255 + strlen( it_attach ).
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      clear t_attachment.
      refresh t_attachment.
      t_attachment[] = pit_attach[].
    * Describe the body of the message
      clear t_packing_list.
      refresh t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      describe table it_message lines t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      append t_packing_list.
    * Add the recipients email address
      clear t_receivers.
      refresh t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      append t_receivers.
      call function 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
          put_in_outbox              = 'X'
          sender_address             = ld_sender_address
          sender_address_type        = ld_sender_address_type
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = w_sent_all
        TABLES
          object_header              = t_object_header
          packing_list               = t_packing_list
          contents_bin               = t_attachment
          contents_txt               = it_message
          receivers                  = t_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.
    * Populate zerror return code
      ld_error = sy-subrc.
    * Populate zreceiver return code
      loop at t_receivers.
        ld_receiver = t_receivers-retrn_code.
      endloop.
    endform.                    "send_file_as_email_attachment
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    * Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
        submit rsconn01 with mode = 'INT'
                      with output = 'X'
                      and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    * Populate message body text
    form populate_email_message_body.
      refresh it_message.
      refresh it_message1.
      refresh it_message3.
       refresh it_message4.
    *--------------- LOOP FOR BSEG -----------------------------------------
      loop at int_BSEG.
    read table int_bKPF WITH KEY BELNR = INT_BSEG-BELNR
            GJAHR = INT_BSEG-GJAHR.
    read table int_SKAT WITH KEY SAKNR = INT_BSEG-HKONT.
    *---CHANGING DATE FORMAT FOR BKPF---------------------------------------
    lv_date1 = int_bkpf-budat.
      var4 = lv_date1+(4).
      var5 = lv_date1+4(2).
      var6 = lv_date1+6(2).
    concatenate var6 var5 var4 into lv_formatdate1 separated by '.'.
    *---END OF CHANGING DATE FORMAT FOR BKPF-------------------------
    it_message =  int_bseg-belnr.
    it_message1 =  lv_formatdate1.
    it_message2 = int_bseg-dmbtr.
    it_message3 = int_bseg-hkont.
    IT_MESSAGE4 = INT_SKAT-TXT50.
    SHIFT IT_MESSAGE2 LEFT DELETING LEADING '0'.
    *-------------POPULATING EMAIL BODY WITH DATA -------------------------
    concatenate 'Maturity After 2Days' 'for'  'G/L account-' it_message3
    '--' IT_MESSAGE4  ',' 'Amount-' it_message2
        into it_message separated by space.
    append it_message.
    append it_message1.
    append it_message3.
      clear it_message.
      clear it_message1.
      clear it_message2.
      clear it_message3.
    endloop.
    *------------END OF LOOP FOR BSEG --------------------------------------
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    <b><i>
    To send an mail with external attachment check this one
    </b></i>
    <i>first create a Include report with the following coding</i>
    *& Include ZPA1_INCLFOR_MAIL *
    * 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
    <b>
    Then include that report in the following report and copy the same code and paste it there
    </b>
    *& Report ZPA_TEMP147 *
    REPORT ZPA_TEMP147 .
    INCLUDE zpa1_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
    <b>These are the FM for sending external email :-</b>
    SO_DOCUMENT_SEND_API1
    SAPoffice: Send new document with attachments via RFC
    SO_NEW_DOCUMENT_ATT_SEND_API1
    (In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
    SAPoffice: Send new document with attachments via RFC
    Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.
    SO_NEW_DOCUMENT_SEND_API1
    SAPoffice: Send new document
    <b>Check this sample report</b>
    DATA : BEGIN OF ITAB OCCURS 0,
    PERNR LIKE PA0001-PERNR,
    ENAME LIKE PA0001-ENAME,
    END OF ITAB.
    DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
    receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
    packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
    listobject LIKE abaplist OCCURS 10,
    compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
    w_object_hd_change LIKE sood1,
    compressed_size LIKE sy-index.
    START-OF-SELECTION.
    SELECT PERNR ENAME
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM PA0001
    WHERE PERNR < 50.
    LOOP AT ITAB.
    WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
    SY-VLINE.
    ENDLOOP.
    * Receivers
    receiver_list-recextnam = '[email protected]'. "-->
    * EMAIL ADDRESS
    RECEIVER_list-RECESC = 'E'. "<-
    RECEIVER_list-SNDART = 'INT'."<-
    RECEIVER_list-SNDPRI = '1'."<-
    APPEND receiver_list.
    * General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    * Mail subject
    w_object_hd_change-objdes = 'Message subject'.
    * Mail body
    APPEND 'Message content' TO message_content.
    * Attachment
    CALL FUNCTION 'SAVE_LIST'
    EXPORTING
    list_index = '0'
    TABLES
    listobject = listobject.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    compressed_size = compressed_size
    TABLES
    in = listobject
    out = compressed_attachment.
    DESCRIBE TABLE compressed_attachment.
    CLEAR packing_list.
    packing_list-transf_bin = 'X'.
    packing_list-head_start = 0.
    packing_list-head_num = 0.
    packing_list-body_start = 1.
    packing_list-body_num = sy-tfill.
    packing_list-objtp = 'ALI'.
    packing_list-objnam = 'Object name'.
    packing_list-objdes = 'Attachment description'.
    packing_list-objlen = compressed_size.
    APPEND packing_list.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    object_hd_change = w_object_hd_change
    object_type = 'RAW'
    owner = sy-uname
    TABLES
    objcont = message_content
    receivers = receiver_list
    packing_list = packing_list
    att_cont = compressed_attachment.
    <b>Settings for sending mail</b>
    Configuring SAP 4.6x Internet mail Gateway
    SAP can be configured to send and receive emails from different sources.This section explains how to integrate SAPOffice with an external emailsystem. Your Internet email must be configured and running prior to this.Email from SAP is forwarded to the users external email system..
    You can configure inbound and outbound forwarding. Outbound flow forwardsa SAP message (eg: update termination) via UNIX sendmail to the intended recepient. Inbound accepts a message from sendmail and places it in the users SAPOffice inbox. Many companies prefer to configure outbound only.
    Configuring outbound forwarding
    SAP configuration
    1. Create your RFC destination for outbound email using transaction SM59
    RFC Destination : SAP_INTERNET_GATEWAY
    Connection Type : T
    Description : SAP internet mail gateway
    Click on 'Explicit Host' if you wanton demand gateway dameon invocation.
    Program : /sapmnt/SID/exe/mlunxsnd
    Target Host : Enter hostname that runs your central instance.
    Click 'Test Connection' and you should seea successfull message.
    2. Shared Office Settings transaction SO16-> Send -> Settings or
    directly via transaction SCOT- SAPconnect Administation
    Nodes - Create
    Node : IMAIL
    Description : SAP internet mail gateway
    RFC Destination : SAP_INTERNET_GATEWAY
    Tick : Internet
    Address Area : *
    Tick : All formats
    Dev. type : Choose an approciate Printer Device
    Set further addresstype : N
    Maximum waiting timefor repeat send attempt procedure : Blank or decide for yourself
    Tick : Node is ready for use
    Setting
    - DefaultDomain : <your company domain>.com
    - Conversionrule : require if your communication device only support one format.
    e.g. if you email system only support the format RAW (ASCII text format)
    Format To Format Ranking Function module
    ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW (convert APAP List)
    Referto note 171698 - SAPconnect: Formats, conversion, device type
    UNIX configuration
    1 .. cd /sapmnt/SID/exe
    2 ..csh
    ..mlsomadm mailgw.ini
    System Name [C11] :
    Client [000] :
    Username : MAILADM
    Password : MAILADM
    Language : E
    Load Balancing :
    Hostname : <hostname>
    System number : <instance_number>
    Gateway hostname: <central_instance_hostname>
    Gateway Service : <instance number>
    Use SAP Router :
    Trace level :
    Sendmail Command [/usr/lib/sendmail -i -f<SENDER_ADDRESS>]:
    Codepage [ISO-8859-1] :
    Trace Level (Outbound) [0] :
    Update file sapmailsid.cfg? [Y]
    Testing whether your configuration is successful
    1. Logon to SAP
    2. Execute transaction SO01
    3. Write a message and send it to <your_internet_email_address>
    4. If you don't see the mail in your internet mailbox, go back and review steps 1-12
    Schedule the SAP Internet Mail Gateway Jobs to start every 5 minutes
    1. Create
    2. Position your cursor at INT
    3. Click Schedule and supply the date and time
    4. Click Schedule periodically and tick Minutes and type in 5
    5. Click Create and you are done
    6. Click Show Scheduling to check
    Problems that you might encounter :-
    If you have set up a node in SCOT and it tests out well but recieve the reply.
    "Cannot process message in node, parameterscannot be converted".
    Make sure the RFC connection is working, and that SapConnect has been installed on the Unix Server or the Microsoft Exchange Server. Originally, I had the same error, and found that nothing had been installed on Unixor Exchange, to support SapConnect.
    In SCOT (View -> System Status), your mail remains at the Intransit column.
    Check you sendmail.cf files (e.g.Sun Solaris /etc/mail/sendmail.cf). Try using the sendmail command to send a test file at the Unix level. You must be able to send mail at theUnix level before you can send mail at the SAP level.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/700b405bacdd5fe10000000a155106/content.htm
    http://www.tamboly.com/SAPEmailConfiguration.html
    Check my previous links
    Mail Send
    sending mails from abap program
    Mail Sending to external email id's
    settings needed for sending emails
    Regards
    Pavan

  • Sending mail from one sap box to other sap box

    how  to send mail from one sap box to other sap box?

    Hi Pavan,
    To send mail Internally check this sample code.
    *& Report  ZMATURITYREPORT                                             *
    *&   Title - Maturity   report                                         *
    *& Module - FI                                                         *
    REPORT  ZMATURITYREPORT.
    tables: bseg.
    SELECTION SCREEN---------------------------------------------------  *
    parameters: p_email type somlreci1-receiver default
    '<b><email_removed_by_moderator></b>.
    Data: p_email(25) type c value <b><hardcoding_removed_by_moderator></b>.
    END OF SELECTION SCREEN -------------------------------------------  *
    --DATA DECLARATION--
    data: it_message type standard table of solisti1 initial size 0
    with header line.
    data: it_message1 type standard table of solisti1 initial size 0
    with header line.
    data: it_message2(10) type N.
    data: it_message3 type standard table of solisti1 initial size 0
    with header line.
    data: it_message4 type standard table of solisti1 initial size 0
    with header line.
    data: it_attach type standard table of solisti1 initial size 0
    with header line.
    data: text(150).
    data: t_packing_list like sopcklsti1 occurs 0 with header line,
          t_contents like solisti1 occurs 0 with header line,
          t_receivers like somlreci1 occurs 0 with header line,
          t_attachment like solisti1 occurs 0 with header line,
          t_object_header like solisti1 occurs 0 with header line,
          w_cnt type i,
          w_sent_all(1) type c,
          w_doc_data like sodocchgi1,
          gd_error type sy-subrc,
          gd_reciever type sy-subrc.
    start-of-selection.
    data: lv_date type sy-datum.
    data: lv_date1 type sy-datum.
    data: lv_formatdate(10) type c.
    data: lv_formatdate1(10) type c.
    data: var1(4) type c,
    var2(2) type c,
    var3(2) type c.
    data: begin of int_bseg occurs 0,
        BELNR LIKE BSEG-BELNR,
        ZUONR LIKE BSEG-ZUONR,
        GJAHR LIKE BSEG-GJAHR,
        DMBTR LIKE BSEG-DMBTR,
        HKONT LIKE BSEG-HKONT,
    end of int_bseg.
    data: begin of int_SKAT occurs 0,
        TXT50 LIKE SKAT-TXT50,
        SAKNR LIKE SKAT-SAKNR,
        KTOPL LIKE SKAT-KTOPL,
    end of int_SKAT.
    data: begin of int_bkpf occurs 0,
          BELNR LIKE BKPF-BELNR,
          BUKRS LIKE BKPF-BUKRS,
          GJAHR LIKE BKPF-GJAHR,
          BUDAT  LIKE BKPF-BUDAT,
    end of int_BKPF.
    data: 2days_out type sy-datum.
    2days_out = sy-datum + 2.
    data: var4(4) type c,
    var5(2) type c,
    var6(2) type c.
    -- END OF DATA DECLARATION--
    --- CONCATENATING AND ARRANGING DATE -
    lv_date = 2days_out.
    var1 = lv_date+(4).
    var2 = lv_date+4(2).
    var3 = lv_date+6(2).
    concatenate var3 var2 var1 into lv_formatdate separated by '.'.
    --- END OF CONCATENATING AND ARRANGING DATE  -
    --SELECTION FOR BSEG--
    select zuonr belnr bukrs GJAHR DMBTR HKONT from bseg into
    corresponding fields of  table int_bseg
    where bukrs = 'company name' and
          ZUONR = lv_formatdate.
    *--END OF SSELECTION FOR BSEG--
    --SELECTION FOR BKPF--
    select  BUDAT BUKRS BELNR GJAHR  from BKPF into
    corresponding fields of table int_BKPF
    where bukrs = 'company name'.
    append int_BKPF.
    --END OF SELECTION FOR BKPF--
    --SELECTION FOR SKAT--
    select SAKNR TXT50 from SKAT into
    corresponding fields of  table int_SKAT
    where KTOPL = 'company name'.
    *and      SAKNR = INT_BSEG-HKONT.
    APPEND INT_SKAT.
    *--END OF SSELECTION FOR SKAT--
    ----POPULATING EMAIL SUBJECT -
    perform populate_email_message_body.
      perform send_file_as_email_attachment
      tables it_message
      it_attach
      using p_email
      'Maturity after 2 days'
      'XLS'
      'filename'
      changing gd_error
      gd_reciever.
    Instructs mail send program for SAPCONNECT to send email(rsconn01)
      perform initiate_mail_execute_program.
    *endif.
    end-of-selection.
    ----END OF POPULATING EMAIL SUBJECT -
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    Send email
    form send_file_as_email_attachment tables pit_message
    pit_attach
    using p_email
    p_mtitle
    p_format
    p_filename
    p_attdescription
    p_sender_address
    p_sender_addres_type
    changing p_error
    p_reciever.
      data: ld_error type sy-subrc,
      ld_reciever type sy-subrc,
      ld_mtitle like sodocchgi1-obj_descr,
      ld_email like somlreci1-receiver,
      ld_format type so_obj_tp ,
      ld_attdescription type so_obj_nam ,
      ld_attfilename type so_obj_des ,
      ld_sender_address like soextreci1-receiver,
      ld_sender_address_type like soextreci1-adr_typ,
      ld_receiver like sy-subrc.
      ld_email = p_email.
      ld_mtitle = p_mtitle.
      ld_format = p_format.
      ld_attdescription = p_attdescription.
      ld_attfilename = p_filename.
      ld_sender_address = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      clear w_doc_data.
      read table it_attach index w_cnt.
      w_doc_data-doc_size =
      ( w_cnt - 1 ) * 255 + strlen( it_attach ).
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      clear t_attachment.
      refresh t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      clear t_packing_list.
      refresh t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      describe table it_message lines t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      append t_packing_list.
    Add the recipients email address
      clear t_receivers.
      refresh t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      append t_receivers.
      call function 'SO_DOCUMENT_SEND_API1'
        EXPORTING
          document_data              = w_doc_data
          put_in_outbox              = 'X'
          sender_address             = ld_sender_address
          sender_address_type        = ld_sender_address_type
          commit_work                = 'X'
        IMPORTING
          sent_to_all                = w_sent_all
        TABLES
          object_header              = t_object_header
          packing_list               = t_packing_list
          contents_bin               = t_attachment
          contents_txt               = it_message
          receivers                  = t_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.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      loop at t_receivers.
        ld_receiver = t_receivers-retrn_code.
      endloop.
    endform.                    "send_file_as_email_attachment
    *& Form INITIATE_MAIL_EXECUTE_PROGRAM
    Instructs mail send program for SAPCONNECT to send email.
    form initiate_mail_execute_program.
      wait up to 2 seconds.
      if gd_error eq 0.
        submit rsconn01 with mode = 'INT'
                      with output = 'X'
                      and return.
      endif.
    endform.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *& Form POPULATE_EMAIL_MESSAGE_BODY
    Populate message body text
    form populate_email_message_body.
      refresh it_message.
      refresh it_message1.
      refresh it_message3.
       refresh it_message4.
    LOOP FOR BSEG -
      loop at int_BSEG.
    read table int_bKPF WITH KEY BELNR = INT_BSEG-BELNR
            GJAHR = INT_BSEG-GJAHR.
    read table int_SKAT WITH KEY SAKNR = INT_BSEG-HKONT.
    *-CHANGING DATE FORMAT FOR BKPF--
    lv_date1 = int_bkpf-budat.
      var4 = lv_date1+(4).
      var5 = lv_date1+4(2).
      var6 = lv_date1+6(2).
    concatenate var6 var5 var4 into lv_formatdate1 separated by '.'.
    *-END OF CHANGING DATE FORMAT FOR BKPF--
    it_message =  int_bseg-belnr.
    it_message1 =  lv_formatdate1.
    it_message2 = int_bseg-dmbtr.
    it_message3 = int_bseg-hkont.
    IT_MESSAGE4 = INT_SKAT-TXT50.
    SHIFT IT_MESSAGE2 LEFT DELETING LEADING '0'.
    POPULATING EMAIL BODY WITH DATA -
    concatenate 'Maturity After 2Days' 'for'  'G/L account-' it_message3
    '--' IT_MESSAGE4  ',' 'Amount-' it_message2
        into it_message separated by space.
    append it_message.
    append it_message1.
    append it_message3.
      clear it_message.
      clear it_message1.
      clear it_message2.
      clear it_message3.
    endloop.
    END OF LOOP FOR BSEG -
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    To send an mail with external attachment check this one
    first create a Include report with the following coding
    *& Include ZPA1_INCLFOR_MAIL *
    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
    Then include that report in the following report and copy the same code and paste it there
    *& Report ZPA_TEMP147 *
    REPORT ZPA_TEMP147 .
    INCLUDE zpa1_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
    These are the FM for sending external email :-
    SO_DOCUMENT_SEND_API1
    SAPoffice: Send new document with attachments via RFC
    SO_NEW_DOCUMENT_ATT_SEND_API1
    (In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
    SAPoffice: Send new document with attachments via RFC
    Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject.
    SO_NEW_DOCUMENT_SEND_API1
    SAPoffice: Send new document
    Check this sample report
    DATA : BEGIN OF ITAB OCCURS 0,
    PERNR LIKE PA0001-PERNR,
    ENAME LIKE PA0001-ENAME,
    END OF ITAB.
    DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
    receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
    packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
    listobject LIKE abaplist OCCURS 10,
    compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
    w_object_hd_change LIKE sood1,
    compressed_size LIKE sy-index.
    START-OF-SELECTION.
    SELECT PERNR ENAME
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM PA0001
    WHERE PERNR < 50.
    LOOP AT ITAB.
    WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
    SY-VLINE.
    ENDLOOP.
    Receivers
    receiver_list-recextnam = '[email protected]'. "-->
    EMAIL ADDRESS
    RECEIVER_list-RECESC = 'E'. "<-
    RECEIVER_list-SNDART = 'INT'."<-
    RECEIVER_list-SNDPRI = '1'."<-
    APPEND receiver_list.
    General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    Mail subject
    w_object_hd_change-objdes = 'Message subject'.
    Mail body
    APPEND 'Message content' TO message_content.
    Attachment
    CALL FUNCTION 'SAVE_LIST'
    EXPORTING
    list_index = '0'
    TABLES
    listobject = listobject.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    compressed_size = compressed_size
    TABLES
    in = listobject
    out = compressed_attachment.
    DESCRIBE TABLE compressed_attachment.
    CLEAR packing_list.
    packing_list-transf_bin = 'X'.
    packing_list-head_start = 0.
    packing_list-head_num = 0.
    packing_list-body_start = 1.
    packing_list-body_num = sy-tfill.
    packing_list-objtp = 'ALI'.
    packing_list-objnam = 'Object name'.
    packing_list-objdes = 'Attachment description'.
    packing_list-objlen = compressed_size.
    APPEND packing_list.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    object_hd_change = w_object_hd_change
    object_type = 'RAW'
    owner = sy-uname
    TABLES
    objcont = message_content
    receivers = receiver_list
    packing_list = packing_list
    att_cont = compressed_attachment.
    Settings for sending mail
    Configuring SAP 4.6x Internet mail Gateway
    SAP can be configured to send and receive emails from different sources.This section explains how to integrate SAPOffice with an external emailsystem. Your Internet email must be configured and running prior to this.Email from SAP is forwarded to the users external email system..
    You can configure inbound and outbound forwarding. Outbound flow forwardsa SAP message (eg: update termination) via UNIX sendmail to the intended recepient. Inbound accepts a message from sendmail and places it in the users SAPOffice inbox. Many companies prefer to configure outbound only.
    Configuring outbound forwarding
    SAP configuration
    1. Create your RFC destination for outbound email using transaction SM59
    RFC Destination : SAP_INTERNET_GATEWAY
    Connection Type : T
    Description : SAP internet mail gateway
    Click on 'Explicit Host' if you wanton demand gateway dameon invocation.
    Program : /sapmnt/SID/exe/mlunxsnd
    Target Host : Enter hostname that runs your central instance.
    Click 'Test Connection' and you should seea successfull message.
    2. Shared Office Settings transaction SO16-> Send -> Settings or
    directly via transaction SCOT- SAPconnect Administation
    Nodes - Create
    Node : IMAIL
    Description : SAP internet mail gateway
    RFC Destination : SAP_INTERNET_GATEWAY
    Tick : Internet
    Address Area : *
    Tick : All formats
    Dev. type : Choose an approciate Printer Device
    Set further addresstype : N
    Maximum waiting timefor repeat send attempt procedure : Blank or decide for yourself
    Tick : Node is ready for use
    Setting
    - DefaultDomain : <your company domain>.com
    - Conversionrule : require if your communication device only support one format.
    e.g. if you email system only support the format RAW (ASCII text format)
    Format To Format Ranking Function module
    ALI RAW 1 SX_OBJECT_CONVERT_ALI_RAW (convert APAP List)
    Referto note 171698 - SAPconnect: Formats, conversion, device type
    UNIX configuration
    1 .. cd /sapmnt/SID/exe
    2 ..csh
    ..mlsomadm mailgw.ini
    System Name [C11] :
    Client [000] :
    Username : MAILADM
    Password : MAILADM
    Language : E
    Load Balancing :
    Hostname : <hostname>
    System number : <instance_number>
    Gateway hostname: <central_instance_hostname>
    Gateway Service : <instance number>
    Use SAP Router :
    Trace level :
    Sendmail Command [/usr/lib/sendmail -i -f<SENDER_ADDRESS>]:
    Codepage [ISO-8859-1] :
    Trace Level (Outbound) [0] :
    Update file sapmailsid.cfg? [Y]
    Testing whether your configuration is successful
    1. Logon to SAP
    2. Execute transaction SO01
    3. Write a message and send it to <your_internet_email_address>
    4. If you don't see the mail in your internet mailbox, go back and review steps 1-12
    Schedule the SAP Internet Mail Gateway Jobs to start every 5 minutes
    1. Create
    2. Position your cursor at INT
    3. Click Schedule and supply the date and time
    4. Click Schedule periodically and tick Minutes and type in 5
    5. Click Create and you are done
    6. Click Show Scheduling to check
    Problems that you might encounter :-
    If you have set up a node in SCOT and it tests out well but recieve the reply.
    "Cannot process message in node, parameterscannot be converted".
    Make sure the RFC connection is working, and that SapConnect has been installed on the Unix Server or the Microsoft Exchange Server. Originally, I had the same error, and found that nothing had been installed on Unixor Exchange, to support SapConnect.
    In SCOT (View -> System Status), your mail remains at the Intransit column.
    Check you sendmail.cf files (e.g.Sun Solaris /etc/mail/sendmail.cf). Try using the sendmail command to send a test file at the Unix level. You must be able to send mail at theUnix level before you can send mail at the SAP level.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/700b405bacdd5fe10000000a155106/content.htm
    http://www.tamboly.com/SAPEmailConfiguration.html
    Check my previous links
    Mail Send
    sending mails from abap program
    Mail Sending to external email id's
    settings needed for sending emails
    <b><points_request_removed_by_moderator></b>
    Cheers,
    CHAITANYA.

  • 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

  • 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

  • Function Module to send a mail in PDF/ XLS format

    Can you please tell me the name of a function module where a mail to be send in a non-sap box. And then mail which will be send is in a PDF/ XLS format.
    Regards,
    Subhasish

    Hi Subhasish,
    These are the FM for sending external email :-
    SO_DOCUMENT_SEND_API1 
    SAPoffice: Send new document with attachments via RFC 
    SO_NEW_DOCUMENT_ATT_SEND_API1
    (In 4.6C only, You can go to SE37 and click the documentation on how to use it. A sample program is provided there.)
    SAPoffice: Send new document with attachments via RFC 
    Note : If you are using FM SO_NEW_DOCUMENT_ATT_SEND_API1 then Export Parameter DOCUMENT_DATA-OBJ_DESCR contains the Subject. 
    SO_NEW_DOCUMENT_SEND_API1 
    SAPoffice: Send new document 
    How to send a report to an external mail-id?
    Try this sample code :-
    REPORT ZREPORT_TO_EMAIL NO STANDARD PAGE HEADING LINE-SIZE 200.
    DATA : BEGIN OF ITAB OCCURS 0,
    PERNR LIKE PA0001-PERNR,
    ENAME LIKE PA0001-ENAME,
    END OF ITAB.
    DATA: message_content LIKE soli OCCURS 10 WITH HEADER LINE,
    receiver_list LIKE soos1 OCCURS 5 WITH HEADER LINE,
    packing_list LIKE soxpl OCCURS 2 WITH HEADER LINE,
    listobject LIKE abaplist OCCURS 10,
    compressed_attachment LIKE soli OCCURS 100 WITH HEADER LINE,
    w_object_hd_change LIKE sood1,
    compressed_size LIKE sy-index.
    START-OF-SELECTION.
    SELECT PERNR ENAME
    INTO CORRESPONDING FIELDS OF TABLE ITAB
    FROM PA0001
    WHERE PERNR < 50.
    LOOP AT ITAB.
    WRITE :/02 SY-VLINE , ITAB-PERNR, 15 SY-VLINE , ITAB-ENAME, 50
    SY-VLINE.
    ENDLOOP.
    Receivers
    receiver_list-recextnam = '[email protected]'. "-->
    EMAIL ADDRESS
    RECEIVER_list-RECESC = 'E'. "<-
    RECEIVER_list-SNDART = 'INT'."<-
    RECEIVER_list-SNDPRI = '1'."<-
    APPEND receiver_list.
    General data
    w_object_hd_change-objla = sy-langu.
    w_object_hd_change-objnam = 'Object name'.
    w_object_hd_change-objsns = 'P'.
    Mail subject
    w_object_hd_change-objdes = 'Message subject'.
    Mail body
    APPEND 'Message content' TO message_content.
    Attachment
    CALL FUNCTION 'SAVE_LIST'
    EXPORTING
    list_index = '0'
    TABLES
    listobject = listobject.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    compressed_size = compressed_size
    TABLES
    in = listobject
    out = compressed_attachment.
    DESCRIBE TABLE compressed_attachment.
    CLEAR packing_list.
    packing_list-transf_bin = 'X'.
    packing_list-head_start = 0.
    packing_list-head_num = 0.
    packing_list-body_start = 1.
    packing_list-body_num = sy-tfill.
    packing_list-objtp = 'ALI'.
    packing_list-objnam = 'Object name'.
    packing_list-objdes = 'Attachment description'.
    packing_list-objlen = compressed_size.
    APPEND packing_list.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    object_hd_change = w_object_hd_change
    object_type = 'RAW'
    owner = sy-uname
    TABLES
    objcont = message_content
    receivers = receiver_list
    packing_list = packing_list
    att_cont = compressed_attachment.
    Reward points if useful..
    Regards,
    Goutham.

Maybe you are looking for