How to send a mail with an attatchment with it

Hi frienz, in my requirement I am asked to write a code to send an e-mail to the mentioned receivers once after the task is completed. If needed the program should send the attatchment also. Pls give some suggestions on this requirement.

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

Similar Messages

  • How to send a mail to the user with attachement

    Hi Experts,
    I have a requirement where user needs to get the automatic mail which has the updated information sheet as the attachement.
    Kindly give me a clue on this.
    if any body has model program for this...kidnly send it to [email protected]
    Thanks in Advance,
    Aiswarya

    HI
    good
    go throug this link
    http://help.sap.com/saphelp_nw04s/helpdata/en/38/71f865c2c9a94ab1dce95792187c16/content.htm
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    go through this report=>
    : Report  ZSAPTALK                                                   :
    : Author  SAPdev.co.uk                                               :
    : Description :                                                      :
    : Send mail message to SAP mail inbox.                               :
    :                     Please visit www.sapdev.co.uk for further info :
    REPORT ZSAPMAIL NO STANDARD PAGE HEADING.
    TABLES: DRAD,
            QINF,
            DRAW,
            SOUC,
            SOFD,
            DRAP.
    DATA: P_RETURN_CODE LIKE SY-SUBRC.
    data: d_username LIKE DRAP-PRNAM.
    mail declarations
    DATA : BEGIN OF NEW_OBJECT_ID.         " the newly created email object
            INCLUDE STRUCTURE SOODK.
    DATA : END OF NEW_OBJECT_ID.
    DATA : BEGIN OF FOLDER_ID.             " the folder id of the outbox
            INCLUDE STRUCTURE SOODK.
    DATA : END OF FOLDER_ID.
    DATA : BEGIN OF REC_TAB OCCURS 5.     " the table which will contain the
            INCLUDE STRUCTURE SOOS1.       " information on the destination
    DATA : END OF REC_TAB.
    DATA : BEGIN OF OBJECT_HD_CHANGE.      " the table which contains the
            INCLUDE STRUCTURE SOOD1.       " info for the object we will be
    DATA : END OF OBJECT_HD_CHANGE.        " creating
    DATA : OBJECT_TYPE LIKE SOOD-OBJTP.    " the type of object
    DATA : BEGIN OF OBJHEAD OCCURS 5.      " the header of the object
            INCLUDE STRUCTURE SOLI.
    DATA : END OF OBJHEAD.
    DATA : BEGIN OF OBJCONT OCCURS 0.      " the contents of the object
            INCLUDE STRUCTURE SOLI.        " i.e. the text etc
    DATA : END OF OBJCONT.
    DATA : BEGIN OF OBJPARA OCCURS 5.      " formatting options
            INCLUDE STRUCTURE SELC.
    DATA : END OF OBJPARA.
    DATA : BEGIN OF OBJPARB OCCURS 5.      " formatting options
            INCLUDE STRUCTURE SOOP1.
    DATA : END OF OBJPARB.
    DATA : BEGIN OF T_MAIL_TEXT OCCURS 0,  "Message table for messages to
            STRING(255),                   "user via mailbox
           END OF T_MAIL_TEXT.
    Parameter: p_uname like sy-uname.
    **START-OF-SELECTION
    START-OF-SELECTION.
        d_username = p_uname.
        PERFORM POPULATE_EMAIL_TEXT.
        PERFORM SETUP_TRX_AND_RTX_MAILBOXES USING P_RETURN_CODE.
        PERFORM CREATE_AND_SEND_MAIL_OBJECT.
          FORM POPULATE_EMAIL_TEXT                                      *
          Inserts text for email message                                *
    FORM POPULATE_EMAIL_TEXT.
      CLEAR T_MAIL_TEXT-STRING.            "puts a blank line in
      APPEND T_MAIL_TEXT.
      APPEND T_MAIL_TEXT.
    adds failed list  on to end of success list.
      T_MAIL_TEXT-STRING = 'Test email message line 1'.
      APPEND T_MAIL_TEXT.
      T_MAIL_TEXT-STRING = 'Test email message line 1'.
      APPEND T_MAIL_TEXT.
      CLEAR T_MAIL_TEXT-STRING.            "puts a blank line in
      APPEND T_MAIL_TEXT.
      T_MAIL_TEXT-STRING = 'Header1    Header2    Header3'.
      APPEND T_MAIL_TEXT.
      T_MAIL_TEXT-STRING = '----
      APPEND T_MAIL_TEXT.
    ENDFORM.
    *&      Form  SETUP_TRX_&_RTX_MAILBOXES
      Ensure that the mailboxes of the sender (INTMGR) are set up OK
    FORM SETUP_TRX_AND_RTX_MAILBOXES USING P_RETURN_CODE.
    get the user no of the sender in order to add the mail to the
    user name's outbox for future reference
      SELECT SINGLE * FROM SOUC
               WHERE SAPNAM = SY-UNAME.    "SAP name of a SAPoffice user
      IF SY-SUBRC NE 0.
        "Error finding the SAPoffice user info for the user
        MESSAGE E064(ZR53) WITH SY-UNAME.
        P_RETURN_CODE = 1.
        EXIT.
      ENDIF.
    *Get the outbox No for the sender from the user No where the folder
                                           " type is an outbox
      SELECT * FROM SOFD WHERE OWNTP = SOUC-USRTP   "Owner type from ID
                           AND OWNYR = SOUC-USRYR   "Owner year from the ID
                           AND OWNNO = SOUC-USRNO   "Owner number from the I
                           AND FOLRG = 'O'."Output box
      ENDSELECT.
      IF SY-SUBRC NE 0.
        " Error getting folder information for the user
        MESSAGE E065(ZR53) WITH SY-UNAME.
        P_RETURN_CODE = 1.
        EXIT.
      ENDIF.
    ENDFORM.                               " SETUP_TRX_&_RTX_MAILBOXES
    *&      Form  CREATE_AND_SEND_MAIL_OBJECT
    FORM CREATE_AND_SEND_MAIL_OBJECT.
      FOLDER_ID-OBJTP = SOFD-FOLTP.        " the folder type ( usually FOL )
      FOLDER_ID-OBJYR = SOFD-FOLYR.        " the folder year ( usually 22 )
      FOLDER_ID-OBJNO = SOFD-FOLNO.        " the folder no.
      OBJECT_TYPE     = 'RAW'.             " the type of object being added
    build up the object information for creating the object
      OBJECT_HD_CHANGE-OBJLA  = SY-LANGU.  " the language of the email
      OBJECT_HD_CHANGE-OBJNAM = 'PS to DM Interface'. " the object name
    mail subject 'Mass Linking of QA, pass/fail'
      MOVE TEXT-002 TO OBJECT_HD_CHANGE-OBJDES.
      OBJECT_HD_CHANGE-DLDAT = SY-DATUM.   " the date of the email
      OBJECT_HD_CHANGE-DLTIM = SY-UZEIT.   " the time of the email
      OBJECT_HD_CHANGE-OBJPRI = '1'.       " the priority ( highest )
      OBJECT_HD_CHANGE-OBJSNS = 'F'.       " the object sensitivity
    F is functional, C - company sensitive
    object_hd_change-skips  = ' '.       " Skip first screen
    object_hd_change-acnam  = 'SM35'.    " Batch imput transaction
    object_hd_change-vmtyp  = 'T'.       " Transaction type
    add the text lines into the contents of the email
      CLEAR OBJCONT.
      REFRESH OBJCONT.
    free objcont.      " added this to delete the mail contents records
      LOOP AT T_MAIL_TEXT.
        OBJCONT-LINE = T_MAIL_TEXT-STRING.
        APPEND OBJCONT.
      ENDLOOP.
      CLEAR OBJCONT.
    build up the table of receivers for the email
      REC_TAB-RCDAT = SY-DATUM.            " the date to send the email
      REC_TAB-RCTIM = SY-UZEIT.            " the time to send the email
    the SAP username of the person who will receive the email
      REC_TAB-RECNAM = D_USERNAME.
    the user type of the person who will send the email ( USR )
      REC_TAB-SNDTP = SOUC-USRTP.
    the user year of the person who will send the email ( 22 )
      REC_TAB-SNDYR = SOUC-USRYR.
    the user number of the person who will send the email
      REC_TAB-SNDNO = SOUC-USRNO.
    the sap username of the person who will send the email
      REC_TAB-SNDNAM = SY-UNAME.
    get the user info for the receiver of the document
      SELECT SINGLE * FROM SOUC WHERE SAPNAM = D_USERNAME.
      IF SY-SUBRC NE 0.
        WRITE : / TEXT-001, D_USERNAME.    "usnam.
        EXIT.
      ENDIF.
    the user number of the person who will receive the email ( USR )
      REC_TAB-RECNO = SOUC-USRNO.
    the user type of the person who will receive the email ( USR )
      REC_TAB-RECTP = SOUC-USRTP.
    the user year of the person who will receive the email ( USR )
      REC_TAB-RECYR = SOUC-USRYR.
    the priority of the email ( highest )
      REC_TAB-SNDPRI = '1'.
    check for delivery on the email
      REC_TAB-DELIVER = 'X'.
    send express so recipient knows there is a problem
      REC_TAB-SNDEX = 'X'.
    check for a return receipt
      REC_TAB-READ = 'X'.
    the sap username of the person receiving the email
      REC_TAB-ADR_NAME = D_USERNAME.       "usnam.
    add this receiver to the internal table
      APPEND REC_TAB.
      CLEAR REC_TAB.
    call the function to create the object in the outbox of the sender
      CALL FUNCTION 'SO_OBJECT_INSERT'
           EXPORTING
                FOLDER_ID                  = FOLDER_ID
                OBJECT_HD_CHANGE           = OBJECT_HD_CHANGE
                OBJECT_TYPE                = OBJECT_TYPE
                OWNER                      = SY-UNAME
           IMPORTING
                OBJECT_ID                  = NEW_OBJECT_ID
           TABLES
                OBJCONT                    = OBJCONT
                OBJHEAD                    = OBJHEAD
                OBJPARA                    = OBJPARA
                OBJPARB                    = OBJPARB
           EXCEPTIONS
                ACTIVE_USER_NOT_EXIST      = 1
                COMMUNICATION_FAILURE      = 2
                COMPONENT_NOT_AVAILABLE    = 3
                DL_NAME_EXIST              = 4
                FOLDER_NOT_EXIST           = 5
                FOLDER_NO_AUTHORIZATION    = 6
                OBJECT_TYPE_NOT_EXIST      = 7
                OPERATION_NO_AUTHORIZATION = 8
                OWNER_NOT_EXIST            = 9
                PARAMETER_ERROR            = 10
                SUBSTITUTE_NOT_ACTIVE      = 11
                SUBSTITUTE_NOT_DEFINED     = 12
                SYSTEM_FAILURE             = 13
                X_ERROR                    = 14
                OTHERS                     = 15.
      IF SY-SUBRC NE 0.
        MESSAGE A063(ZR53) WITH SY-SUBRC.
        EXIT.
      ENDIF.
    call the function to send the already created email to the receivers
      CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                FOLDER_ID                  = FOLDER_ID
                OBJECT_ID                  = NEW_OBJECT_ID
                OUTBOX_FLAG                = 'X'
                OWNER                      = SY-UNAME
           TABLES
                RECEIVERS                  = REC_TAB
           EXCEPTIONS
                ACTIVE_USER_NOT_EXIST      = 1
                COMMUNICATION_FAILURE      = 2
                COMPONENT_NOT_AVAILABLE    = 3
                FOLDER_NOT_EXIST           = 4
                FOLDER_NO_AUTHORIZATION    = 5
                FORWARDER_NOT_EXIST        = 6
                NOTE_NOT_EXIST             = 7
                OBJECT_NOT_EXIST           = 8
                OBJECT_NOT_SENT            = 9
                OBJECT_NO_AUTHORIZATION    = 10
                OBJECT_TYPE_NOT_EXIST      = 11
                OPERATION_NO_AUTHORIZATION = 12
                OWNER_NOT_EXIST            = 13
                PARAMETER_ERROR            = 14
                SUBSTITUTE_NOT_ACTIVE      = 15
                SUBSTITUTE_NOT_DEFINED     = 16
                SYSTEM_FAILURE             = 17
                TOO_MUCH_RECEIVERS         = 18
                USER_NOT_EXIST             = 19
                X_ERROR                    = 20
                OTHERS                     = 21.
      IF SY-SUBRC EQ 0.
        MESSAGE I035(ZR53) WITH NEW_OBJECT_ID D_USERNAME. "usnam.
      ELSE.
        MESSAGE I036(ZR53) WITH D_USERNAME."      sy-subrc.
      ENDIF.
    ENDFORM.                               " CREATE_AND_SEND_MAIL_OBJECT
    thanks
    mrutyun

  • How to send a mail with HTML body from Oracle

    Hi Team,
    Can somebody guide me how to send a mail with HTML body from oracle.
    Here is the piece of code i am trying to send a mail.
    procedure SEND_MAIL is
    cursor c_1 is select * from table_name;
    l_mail_id varchar2(40);
    -- ls_mailhost VARCHAR2(64) := Mailhost;
    ls_from VARCHAR2(64) := ‘[email protected]
    ls_subject VARCHAR2(200);
    ls_to VARCHAR2(64);
    l_mail_conn UTL_SMTP.connection;
    ls_left_menu_name VARCHAR2(64);
    ll_emp_num number(8);
    begin
    for i in c_1 loop
    begin
    l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
    UTL_SMTP.HELO(l_mail_conn, 'IP');
    UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
    UTL_SMTP.RCPT(L_mail_conn, LS_TO);
    UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
    'To: ' ||ls_to || utl_tcp.crlf ||
    'Subject: ' ||ls_subject|| utl_tcp.crlf);
    UTL_SMTP.QUIT(l_mail_conn);
    exception
    when no_data_found then
    null;
    when others then
    RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
    end;
    end loop;
    end;
    Thnx

    Hi Nicolas!
    Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
    If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
    SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
    Hope this helps!
    Regards
    Geir

  • How to send HTML mail with images multipart/related message

    Hi,
    Could any body tell me how to send HTML mail with images in "multipart/related" message,if any body can give the code ,it would be helpful.
    Thanks

    Hi,
    Could any body tell me how to send HTML mail with
    ith images in "multipart/related" message,if any body
    can give the code ,it would be helpful.
    ThanksHi!
    Refer to
    http://developer.java.sun.com/developer/onlineTraining/JavaMail/index.html
    I've found it very helpful.
    Look at the last part for a code showing how to send HTML mail!
    Regards

  • How to send a mail by ckicking the button using java

    hi,
    how to send a mail by clicking the button (like payroll silp in that contain one button if we click that it autometically go through the mail as a attachment) pls frd to me my gmail is [email protected]

    Hi,
    It seems we are doing the homework for you; to make you start with something; look at the sample code below and try to understand it first then put the right values
    to send an email with an attachement.
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.util.Date;
    import java.util.Properties;
    import javax.activation.DataHandler;
    import javax.activation.FileDataSource;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    import javax.swing.AbstractAction;
    import javax.swing.Action;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    public class Main {
          * @param args
         public static void main(String[] args) {
              // Create the frame
              String title = "Frame Title";
              JFrame frame = new JFrame(title);
              // Create a component to add to the frame
              JComponent comp = new JTextField();
              Action action = new AbstractAction("Button Label") {
                   // This method is called when the button is pressed
                   public void actionPerformed(ActionEvent evt) {
                        System.out.println("sending email with attachment");
                        sendEmail();
              // Create the button
              JButton button = new JButton(action);
              // Add the component to the frame's content pane;
              // by default, the content pane has a border layout
              frame.getContentPane().add(comp, BorderLayout.SOUTH);
              frame.getContentPane().add(button, BorderLayout.NORTH);
              // Show the frame
              int width = 300;
              int height = 300;
              frame.setSize(width, height);
              frame.setVisible(true);
         protected static void sendEmail() {
              String from = "me@localhost";
              String to = "me@localhost";
              String subject = "Important Message";
              String bodyText = "This is a important message with attachment";
              String filename = "c:\\tmp\\message.pdf";
              Properties properties = new Properties();
              properties.put("mail.stmp.host", "localhost");
              properties.put("mail.smtp.port", "25");
              Session session = Session.getDefaultInstance(properties, null);
              try {
                   MimeMessage message = new MimeMessage(session);
                   message.setFrom(new InternetAddress(from));
                   message.setRecipient(Message.RecipientType.TO, new InternetAddress(
                             to));
                   message.setSubject(subject);
                   message.setSentDate(new Date());
                   // Set the email message text.
                   MimeBodyPart messagePart = new MimeBodyPart();
                   messagePart.setText(bodyText);
                   // Set the email attachment file
                   MimeBodyPart attachmentPart = new MimeBodyPart();
                   FileDataSource fileDataSource = new FileDataSource(filename) {
                        @Override
                        public String getContentType() {
                             return "application/octet-stream";
                   attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                   attachmentPart.setFileName(filename);
                   Multipart multipart = new MimeMultipart();
                   multipart.addBodyPart(messagePart);
                   multipart.addBodyPart(attachmentPart);
                   message.setContent(multipart);
                   Transport.send(message);
              } catch (MessagingException e) {
                   e.printStackTrace();
    }The sample above is not ideal so you need to go through it and start to ask me some questions if you have
    Let me know if you miss something
    Regards,
    Alan Mehio
    London,UK

  • How to send a mail to the user when a job gets canceled?

    Hi experts,
                      I need to send a mail when a job gets canceled to the user.I know the FM for sending mail and i can find if a job is canceled from tbtco,but i want to know how to send the mail from the same program ,once it got canceled ?
    thanks in advance,
    helpful answers will be awarded with points
    regards,
    ashwin

    Hi Ashwin
    Use the below peace of code:
    REPORT ZBCJOBMONITOR .
    TABLES: SOMLREC90,
            TBTCO.
    DATA: MAILDATA   LIKE SODOCCHGI1.
    DATA: MAILTXT    LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.
    DATA: MAILREC    LIKE SOMLREC90 OCCURS 0  WITH HEADER LINE.
    DATA: I_TBTCO    LIKE TBTCO OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
    SELECT-OPTIONS: S_JOB FOR TBTCO-JOBNAME.
    SELECT-OPTIONS: S_JOBC FOR TBTCO-JOBClass.
    SELECT-OPTIONS: S_REC FOR SOMLREC90-RECEIVER.
    SELECTION-SCREEN END OF BLOCK B1.
    START-OF-SELECTION.
      CLEAR:    MAILDATA, MAILTXT, MAILREC, I_TBTCO.
      REFRESH:  MAILTXT, MAILREC, I_TBTCO.
      PERFORM GET_ABENDED_JOBS.
      PERFORM BUILD_RECEIVERS.
      LOOP AT I_TBTCO.
        PERFORM BUILD_TEXT_MESSAGE.
        PERFORM SEND_MAIL_NODIALOG..
      ENDLOOP.
         Form  BUILD_TEXT_MESSAGE
    FORM GET_ABENDED_JOBS.
      SELECT * FROM TBTCO
              INTO CORRESPONDING FIELDS OF TABLE I_TBTCO
                         WHERE JOBNAME IN S_JOB
                           AND STATUS = 'A'
                           AND JOBCLASS IN S_JOBC
                           AND SDLSTRTDT = SY-DATUM.
    ENDFORM.
         Form  BUILD_TEXT_MESSAGE
    FORM BUILD_TEXT_MESSAGE.
      DATA: DATE(10) TYPE C.
      DATA: TIME(10) TYPE C.
      MAILDATA-OBJ_NAME = 'MONITOR'.
      MAILDATA-OBJ_DESCR = 'Batch Job Monitor'.
      MAILDATA-OBJ_LANGU = SY-LANGU.
      CONCATENATE 'Job Name:' I_TBTCO-JOBNAME
                  INTO MAILTXT-LINE SEPARATED BY SPACE.
      APPEND MAILTXT.
      PERFORM FORMAT_DATE USING I_TBTCO-SDLSTRTDT
                                DATE.
      CONCATENATE I_TBTCO-SDLSTRTTM+0(2) ':'
                  I_TBTCO-SDLSTRTTM+2(2) ':'
                  I_TBTCO-SDLSTRTTM+4(2)
                     INTO TIME.
      CONCATENATE 'Start Date/Time:' DATE TIME
                INTO MAILTXT-LINE SEPARATED BY SPACE.
      APPEND MAILTXT.
      CONCATENATE 'Job Class:' I_TBTCO-JOBCLASS
                INTO MAILTXT-LINE SEPARATED BY SPACE.
      APPEND MAILTXT.
      MAILTXT-LINE = 'Job has terminated abnormally'.
      APPEND MAILTXT.
    ENDFORM.
         Form  BUILD_RECEIVERS
    FORM BUILD_RECEIVERS.
      LOOP AT S_REC.
        CLEAR MAILREC.
        MAILREC-RECEIVER = S_REC-LOW.
        MAILREC-REC_TYPE  = 'U'.
        APPEND MAILREC.
      ENDLOOP.
    ENDFORM.
         Form  SEND_MAIL_NODIALOG
    FORM SEND_MAIL_NODIALOG.
      CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = MAILDATA
                DOCUMENT_TYPE              = 'RAW'
                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.
    ENDFORM.
         Form FORMAT_DATE
    FORM FORMAT_DATE USING IN
                           OUT.
      CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
           EXPORTING
                DATE_INTERNAL            = IN
           IMPORTING
                DATE_EXTERNAL            = OUT
           EXCEPTIONS
                DATE_INTERNAL_IS_INVALID = 1
                OTHERS                   = 2.
    ENDFORM.
    Regards,
    Sree

  • How to send a mail to a person  from after completeing bdc .

    Hi Xperts,
    Please send me a options how to send a mail to a person after completing a bdc or from any report program.
    mailed can be a sapuser or other service provider(ex:yahoo,gmail.any thing)
    Please Any one i want it now .
    Thank You.

    FUNCTION RS_SEND_MAIL_FOR_SPOO* Email ITAB structure
    DATA: BEGIN OF EMAIL_ITAB OCCURS 10.
            INCLUDE STRUCTURE SOLI.
    DATA: END OF EMAIL_ITAB.
    DATA: T_EMAIL LIKE SOOS1-RECEXTNAM.  "EMail distribution list
    CONSTANTS: C_EMAIL_DISTRIBUTION LIKE SOOS1-RECEXTNAM VALUE
               ‘[email protected],[email protected]’.
    Initialization
    REFRESH EMAIL_ITAB.
    Populate data
    EMAIL_ITAB-LINE = ‘Email body text 1’.
    APPEND EMAIL_ITAB.
    EMAIL_ITAB-LINE = ‘Email body text 2’.
    APPEND EMAIL_ITAB.
    T_EMAIL = C_EMAIL_DISTRIBUTION.
    --- EMAIL FUNCTION ---------------------------------------------------
    REQUIRMENTS:
    1) The user running the program needs a valid email address in their
       address portion of tx SU01 under external comms -> SMTP -> internet
       address.
    2) A job called SAP_EMAIL is running with the following parameters:
       Program: RSCONN01  Variant: INT   User: XXX
       This program moves mail from the outbox to the mail server using
       RFC destination: SAP_INTERNET_GATEWAY_SERVER
    INTERFACE:
    1) APPLICATION: Anything
    2) EMAILTITLE:  EMail subject
    3) RECEXTNAM:   EMail distribution lists separated by commas
    4) TEXTTAB:     Internal table for lines of the email message
    EXCEPTIONS:
    Send OK = 0 otherwise there was a problem with the send.
        CALL FUNCTION 'Z_SEND_EMAIL_ITAB'
             EXPORTING
                  APPLICATION = 'EMAIL'
                  EMAILTITLE  = 'Email Subject'
                  RECEXTNAM   = T_EMAIL
             TABLES
                  TEXTTAB     = EMAIL_ITAB
             EXCEPTIONS
                  OTHERS      = 1.
    Function Z_SEND_EMAIL_ITAB
    ""Local interface:
    *"       IMPORTING
    *"             VALUE(APPLICATION) LIKE  SOOD1-OBJNAM
    *"             VALUE(EMAILTITLE) LIKE  SOOD1-OBJDES
    *"             VALUE(RECEXTNAM) LIKE  SOOS1-RECEXTNAM
    *"       TABLES
    *"              TEXTTAB STRUCTURE  SOLI
    *- local data declaration
      DATA: OHD    LIKE SOOD1,
            OID    LIKE SOODK,
            TO_ALL LIKE SONV-FLAG,
            OKEY   LIKE SWOTOBJID-OBJKEY.
      DATA: BEGIN OF RECEIVERS OCCURS 0.
              INCLUDE STRUCTURE SOOS1.
      DATA: END OF RECEIVERS.
    *- fill odh
      CLEAR OHD.
      OHD-OBJLA    = SY-LANGU.
      OHD-OBJNAM   = APPLICATION.
      OHD-OBJDES   = EMAILTITLE.
      OHD-OBJPRI   = 3.
      OHD-OBJSNS   = 'F'.
      OHD-OWNNAM   = SY-UNAME.
    *- send Email
      CONDENSE RECEXTNAM NO-GAPS.
      CHECK RECEXTNAM <> SPACE AND RECEXTNAM CS '@'.
    *- for every individual recipient send an Email
    (see OSS message 0120050409/0000362105/1999)
      WHILE RECEXTNAM CS ','.
        PERFORM INIT_REC TABLES RECEIVERS.
        READ TABLE RECEIVERS INDEX 1.
        RECEIVERS-RECEXTNAM = RECEXTNAM+0(SY-FDPOS).
        ADD 1 TO SY-FDPOS.
        SHIFT RECEXTNAM LEFT BY SY-FDPOS PLACES.
        MODIFY RECEIVERS INDEX 1.
        PERFORM SO_OBJECT_SEND_REC
         TABLES TEXTTAB RECEIVERS
          USING OHD.
      ENDWHILE.
    *- check last recipient in recipient list
      IF RECEXTNAM <> SPACE.
        PERFORM INIT_REC TABLES RECEIVERS.
        READ TABLE RECEIVERS INDEX 1.
        RECEIVERS-RECEXTNAM = RECEXTNAM.
        MODIFY RECEIVERS INDEX 1.
        PERFORM SO_OBJECT_SEND_REC
         TABLES TEXTTAB RECEIVERS
          USING OHD.
      ENDIF.
    ENDFUNCTION.
          FORM SO_OBJECT_SEND_REC                                       *
    FORM  SO_OBJECT_SEND_REC
    TABLES  OBJCONT      STRUCTURE SOLI
            RECEIVERS    STRUCTURE SOOS1
    USING   OBJECT_HD    STRUCTURE SOOD1.
      DATA:   OID     LIKE SOODK,
              TO_ALL  LIKE SONV-FLAG,
              OKEY    LIKE SWOTOBJID-OBJKEY.
      CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                EXTERN_ADDRESS             = 'X'
                OBJECT_HD_CHANGE           = OBJECT_HD
                OBJECT_TYPE                = 'RAW'
                OUTBOX_FLAG                = 'X'
                SENDER                     = SY-UNAME
           IMPORTING
                OBJECT_ID_NEW              = OID
                SENT_TO_ALL                = TO_ALL
                OFFICE_OBJECT_KEY          = OKEY
           TABLES
                OBJCONT                    = OBJCONT
                RECEIVERS                  = RECEIVERS
           EXCEPTIONS
                ACTIVE_USER_NOT_EXIST      = 1
                COMMUNICATION_FAILURE      = 2
                COMPONENT_NOT_AVAILABLE    = 3
                FOLDER_NOT_EXIST           = 4
                FOLDER_NO_AUTHORIZATION    = 5
                FORWARDER_NOT_EXIST        = 6
                NOTE_NOT_EXIST             = 7
                OBJECT_NOT_EXIST           = 8
                OBJECT_NOT_SENT            = 9
                OBJECT_NO_AUTHORIZATION    = 10
                OBJECT_TYPE_NOT_EXIST      = 11
                OPERATION_NO_AUTHORIZATION = 12
                OWNER_NOT_EXIST            = 13
                PARAMETER_ERROR            = 14
                SUBSTITUTE_NOT_ACTIVE      = 15
                SUBSTITUTE_NOT_DEFINED     = 16
                SYSTEM_FAILURE             = 17
                TOO_MUCH_RECEIVERS         = 18
                USER_NOT_EXIST             = 19
                X_ERROR                    = 20
                OTHERS                     = 21.
      IF SY-SUBRC <> 0.
        RAISE OTHERS.
      ENDIF.
    ENDFORM.
          FORM INIT_REC                                                 *
    FORM INIT_REC TABLES RECEIVERS STRUCTURE SOOS1.
      CLEAR RECEIVERS.
      REFRESH RECEIVERS.
      MOVE SY-DATUM  TO RECEIVERS-RCDAT .
      MOVE SY-UZEIT  TO RECEIVERS-RCTIM.
      MOVE '1'       TO RECEIVERS-SNDPRI.
      MOVE 'X'       TO RECEIVERS-SNDEX.
      MOVE 'U-'      TO RECEIVERS-RECNAM.
      MOVE 'U'       TO RECEIVERS-RECESC.
      MOVE 'INT'     TO RECEIVERS-SNDART.
      MOVE '5'       TO RECEIVERS-SORTCLASS.
      APPEND RECEIVERS.
    ENDFORM.
    2.

  • How to send a Mail purchase order automaticaly from ME22N

    How to send a Mail purchase order automaticaly from ME22N

    Hi,
    First create an entry via NACE with medium =   5 ( External send ) with all other details same as normal print option. Now ensure that vendor master of the po has got the external e-mail id of the vendor. Now go to ME22n in mesages create a message with medium = 5 ( External Send ). Go to communication method, key in Communication strategy.Go to Further date & against Despatch time pick up option 4 viz. Send immeidately while saving an application. Now once you press the save button it will be sent to the address maintained in the vendor master of the vendor of the PO. Please note you require some basic settings from BASIS side as well.
    I hope this helps,
    You may also refer to the SAP note 191470.
    Regards
    Raju Chitale

  • How to Send a Mail

    Hi All:
    I am very new to use this type of issue in my application i have requirement like this there is a column in the report where if it cross the limit a mail trigger must send to the concerened person saying limit exceed
    how to do this i a very new to use this issue in sending a automatic mail plesae help me how to send a mail
    thanks
    sudhir

    I have created your access-list rule without effect ... I try to answer to your questions (sorry, I an a novice in cisco management)
    1) How and where is the acl applied ?
    I don't know !!! In fact, I think that I don't really know what the acl is !!! Is it the same think that the security policy ?
    2) Will you need DNS ?
    Yes. But DNS isn't a problem because I have created rule to check dns in my LAN and the DNS requests are OK (for example with a nslookup on my server)
    3) Check the hit count
    What is the hit count ?
    Sorry for my gaps !!!
    Thanks for your help

  • How to send automatic mail and put attache file on batch file ?

    how to send automatic mail and put attache file on batch file ?
    START MAILTO:[email protected]?SUBJECT=PHONE%CALL^&BODY=Testing

    Hi,
    Do you want to use a batch file to create new email message (including recipients, subject and email body) with attachments? If so, I'd recommend you post your question in the Scripting Guys forum for further assistance:
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?forum=ITCG
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Please feel free to let me know if I've misunderstood something.
    Regards,
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • How to send external mails to the user

    Dears,
    How to send external mails to the user who creates the sales document (Quotation)
    Can you please suggest what modification required in the FM
    Thanks,
    pinky

    You can have a partner function like 'Created by' and use an exit to populate the User ID to this partner function(dont have the system right now but i think this can be done with standard partner detr. procedure also)
    Then, create an Output type for that Partner function with transmission medium as 'External Send'. You can use the standard SAP program to trigger the email. To send the actual email after the output is trigerred, the link connection has to be set up be BASIS but if you want to check, then goto SOST and see if the email got trigerred or not.

  • HT5361 How to send a mail to my entire contact list of my Mail app ?

    How to send a mail to my entire contact list of my Mail app ?

    Hello Madhu,
    The only way to send an email without opening a client is: using server-side mail objects invoked by your app.
    This would be the workflow:
    - your user fills in form data (subject, body, mail_to)
    - your application sends form data to a server (via httpservice or webservice or AMF)
    - the server takes care of sending the mail in a way that is transparent to your user
    So: it is not possible to send emails without opening the iPhone client (I think by "outlook" you mean the "mail client" with an Exchange account) for security reasons. You wouldn't want any app to send mails without you pressing "Send" in a known interface.

  • Sending a mail from Orale APEX with File Attachments

    Hi All,
    I want one solution, i need to send a mail from my application with HTMLDB_MAIL.SEND package and i need to know wheather we can send a mail with file attachments in APEX,if it is possible then how can i send,Can any body please help me with this.
    Thanks

    dil84 wrote:
    Hi All,
    I want one solution, i need to send a mail from my application with HTMLDB_MAIL.SEND package and i need to know wheather we can send a mail with file attachments in APEX,if it is possible then how can i send,Can any body please help me with this.
    ThanksEmail attachments arrived with Apex version 3.1.

  • How to send a mail in workflow keeping 1 receiver in CC and the other in TO

    Hi,
    Can anybody tell me how to send a mail in workflow keeping 1 receiver in CC and the other in TO.
    I need to send a mail to an employee keeping his/her manager in CC through workflow.
    Regards,
    Lavanya

    Hi Lavanya,
    I dont think its possible using Send mail step type.
    But it can be done by using the FM SO_NEW_DOCUMENT_SEND_API1. Just create a method and Call this FM accordingly.
    Thanks,
    Viji.

  • How to send a mail in pdf format file in sbwp??

    how to send a mail in pdf format file in sbwp?? and how to read the content of the mail?

    Refer the following link for Sample Program:
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm

  • How to send E-mails using JSP

    I developed a system where users can login and check for updated information and documents. But the changes are made once or twice in a year. I want to send email after changing the documents. I stored email addresses in the DB. Now the question is how to send e-mails to concerned users without using external software (Outlook, etc.). [Considering same subject and message for all e-mails.]

    Go to Java Mail forum:
    http://forum.java.sun.com/forum.jsp?forum=43

Maybe you are looking for