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]

Similar Messages

  • How to send a mail with PDF attachment

    Hello
    Good Day!
    We have a requirement to send the mail with pdf attachment. Pdf file will be remain same for all mails and it will be placed at server. We are on R12.4 and below is the database information :
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    Thanks a ton for your anticipated help!
    Thanks
    Gaurav

    The word URGENT is considered as rude in this forum.. Nobody here is getting paid for the ansers they are giving..
    Just have a look at These threads.Those will help you.

  • How to send a mail as an attachment in a mail with AppleScript?

    Hi,
    I want to manage my spam using the advices found in support.apple website :
    OS X Mail
    Open the message and choose “Forward as Attachment” from the Message menu.
    Forward the message to iCloud [email protected].
    Forward the message again to abuse@domain, replacing domain with the part of the sender's email address after the @ symbol. For example, if the sender's email address is [email protected], forward the message to [email protected].
    I don't know how to make a message as an attachment...
    set theAttachment to theMessage
    make new attachment with properties {file name:theAttachment} at after last paragraph
    Here is my whole script, if it runs, it could be useful :
    tell application "Mail"
      -- envoi les messages sélectionnés en PJ à [email protected]
              set theMessages to the selection
              repeat with theMessage in theMessages
                        set theAttachment to theMessage
                        set newMessage to make new outgoing message at end of outgoing messages
                        tell newMessage
                                  set subject to "Fwd: " & theMessage's subject
      make new to recipient with properties {address:"[email protected]"}
                                  tell content of theMessage
      make new attachment with properties {file name:theAttachment} at after last paragraph
                                  end tell
                        end tell
      send newMessage
              end repeat
      -- envoi les messages sélectionnés en PJ à abuse@<domaine du spammeur>
              set theMessages to the selection
              repeat with theMessage in theMessages
                        set theAttachment to theMessage
                        set newMessage to make new outgoing message at end of outgoing messages
                        tell newMessage
                                  set subject to "Fwd: " & theMessage's subject
                                  set theSpamAddress to theMessage's sender
                                  set AppleScript's text item delimiters to {"@"}
                                  set spamerDomainName to text item 2 of theSpamAddress
                                  set theNewSpamAddress to "abuse@" & spamerDomainName
      make new to recipient with properties {address:theNewSpamAddress}
                                  tell content of theMessage
      make new attachment with properties {file name:theAttachment} at after last paragraph
                                  end tell
                        end tell
      send newMessage
              end repeat
    end tell
    Thank you!

    Perfect!
    You clearly give me the way. Actually I have used the AppleScript Language Guide from https://developer.apple.com to finalize my AppleScript.
    You just need to select the spam message(s) in "Mail" application, then run the script.
    As I mentionned previously, it just do this automatically :
    OS X Mail
    Open the message and choose “Forward as Attachment” from the Message menu.
    Forward the message to iCloud [email protected].
    Forward the message again to abuse@domain, replacing domain with the part of the sender's email address after the @ symbol. For example, if the sender's email address is [email protected], forward the message to [email protected].
    Here is the entire working script :
    -- Ce script permet de lutter contre le spam.
    -- Je me suis appuyé sur les conseils sur http://support.apple.com/kb/TS4019?viewlocale=fr_FR
    tell application "Mail"
              set theMessages to the selection
              repeat with theMessage in theMessages
      -- enregistre le message dans un fichier pour le mettre en PJ ensuite
                        set msgContent to source of theMessage
                        set tmpFile to ((path to desktop) as rich text) & "ForwardedMessage"
                        set referenceNumber to open for access tmpFile with write permission
      write msgContent to referenceNumber
      close access referenceNumber
      -- envoi le message sélectionné en PJ à [email protected]
                        set newMessage to make new outgoing message at end of outgoing messages
                        tell newMessage
                                  set subject to "Fwd: " & theMessage's subject
      make new to recipient with properties {address:"[email protected]"}
                                  tell content of newMessage
      make new attachment with properties {file name:tmpFile} at after last paragraph
                                  end tell
                        end tell
      send newMessage
      -- envoi le message sélectionné en PJ à abuse@<domaine du spammeur>
                        set newMessage to make new outgoing message at end of outgoing messages
                        tell newMessage
                                  set subject to "Fwd: " & theMessage's subject
                                  set theSpamAddress to theMessage's sender
                                  set AppleScript's text item delimiters to {"@"}
                                  set theSpamAddress to text item 2 of theSpamAddress
                                  set AppleScript's text item delimiters to {">"}
                                  set spamerDomainName to text item 1 of theSpamAddress
                                  set theNewSpamAddress to "abuse@" & spamerDomainName
      make new to recipient with properties {address:theNewSpamAddress}
                                  tell content of newMessage
      make new attachment with properties {file name:tmpFile} at after last paragraph
                                  end tell
                        end tell
      send newMessage
              end repeat
    end tell

  • How to send a mail as .txt attachment ,As data is seperated by pipeline

    Hi ,
    I got a requirement to send a mail in .txt format (Using OOPS) and the data inside the mail is seperated by '|'  Pls help me in this regard.
    i have written a mail to send the mail in .xls it is working fine for me in .xls but i dont know how to write the same for txt where data should be seperated by '|'.
    Regards
    sas
    Ps:  i am attaching my code. and please specify where i need to modify to achieve the same. and any perfromance enhacements are also welcome.
    *& Report  ZGBTEST02
    REPORT  YSAS_MAIL2.
    *Changes done by sas
    *PARAMETERS: P_MAIL TYPE AD_SMTPADR OBLIGATORY, " G C by sas
    *P_MAIL1 TYPE AD_SMTPADR OBLIGATORY." G by sas
    tables: adr6.
    SELECT-OPTIONS:p_eaddr FOR adr6-SMTP_ADDR NO INTERVALS .
    *end of changes by sas
    DATA: I_GLT0 TYPE STANDARD TABLE OF GLT0.
    DATA: I_MARA  TYPE STANDARD TABLE OF MARA.  " MARA Entries
    *      I_MARC  TYPE STANDARD TABLE OF MARC.  " MARC Entries
    DATA: L_TEXT  TYPE CHAR255.  " Text
    DATA: L_LINES TYPE I,
          L_SIZE  TYPE SOOD-OBJLEN.
    " Size of Attachment
    * Mail related
    DATA: I_CONTENT         TYPE   SOLI_TAB, " Mail content
          I_ATTACH          TYPE   SOLI_TAB, " Attachment
          I_ATTACH1         TYPE   SOLIX_TAB. " Attachment
    DATA: L_SEND_REQUEST    TYPE REF TO    CL_BCS,
                                                " E-Mail Send Request
          L_DOCUMENT        TYPE REF TO    CL_DOCUMENT_BCS,
                                                " E-Mail Attachment
          L_RECIPIENT       TYPE REF TO    IF_RECIPIENT_BCS,
                                                " Distribution List
          L_SENDER          TYPE REF TO    IF_SENDER_BCS,
                                                " Address of Sender
          L_UNAME           TYPE           SALRTDRCPT,
                                                " Sender Name(SY-UNAME)
          L_BCS_EXCEPTION   TYPE REF TO    CX_DOCUMENT_BCS,
                                                " BCS Exception
          L_ADDR_EXCEPTION  TYPE REF TO    CX_ADDRESS_BCS,
                                                " Address Exception
          L_SEND_EXCEPTION  TYPE REF TO    CX_SEND_REQ_BCS.
    " E-Mail sending Exception
    *Constants------------------------------------------------------------*
    CONSTANTS: C_TAB(1) TYPE C VALUE
               CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
                                         " Tab Character
               C_CR(1)  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF,
                                         " Line Feed for End-Of_line
               C_EXT    TYPE SOODK-OBJTP VALUE 'XLS'. " XLS Extension
    START-OF-SELECTION.
      SELECT * FROM MARA INTO TABLE I_MARA UP TO 20 ROWS.
      IF SYST-SUBRC EQ 0.
    *    SELECT * FROM MARC INTO TABLE I_MARC FOR ALL ENTRIES IN I_MARA WHERE MATNR = I_MARA-MATNR.
      ENDIF.
    *select * from glt0 into table i_glt0.
    * Preparing body of the Mail
      MOVE 'SAP Material Master Records' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      CLEAR L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE 'Thanks,' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE 'SAP MM' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    * Creates persistent send request
      TRY.
          L_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
    * Creating Document
          L_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                                        I_TYPE  = 'RAW'
                                        I_TEXT  = I_CONTENT[]
                                        I_SUBJECT = 'SAS MASTER Records' ).
    * Preparing contents of attachment with Change Log
          PERFORM PREPARE_ATTACHMENT.
          DESCRIBE TABLE I_MARA LINES L_LINES.
    * Size to multiplied by 2 for UNICODE enabled systems
          L_SIZE = L_LINES * 2 * 255.
    * Adding Attachment
          CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
            EXPORTING
              I_ATTACHMENT_TYPE    = C_EXT
              I_ATTACHMENT_SIZE    = L_SIZE
              I_ATTACHMENT_SUBJECT = 'MARA Details'
    *          i_att_content_hex    = i_attach[].
              I_ATT_CONTENT_TEXT   = I_ATTACH[].
    *      DESCRIBE TABLE I_MARC LINES L_LINES.
    * Size to multiplied by 2 for UNICODE enabled systems
    *      L_SIZE = L_LINES * 2 * 255.
    ** Adding Attachment
    *      CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
    *        EXPORTING
    *          I_ATTACHMENT_TYPE    = C_EXT
    *          I_ATTACHMENT_SIZE    = L_SIZE
    *          I_ATTACHMENT_SUBJECT = 'MARC Details'
    *          I_ATT_CONTENT_HEX    = I_ATTACH1[].
    **          i_att_content_text   = i_attach1[].
    * Add document to send request
          CALL METHOD L_SEND_REQUEST->SET_DOCUMENT( L_DOCUMENT ).
          DATA:LR_SENDER TYPE REF TO IF_SENDER_BCS,
               LR_SEND TYPE REF TO CL_BCS.
    * Preparing the sender object
    *      LR_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( sy-uname ).
           DATA: L1_UNAME TYPE SY-UNAME.
           L1_UNAME = SY-UNAME.
           LR_SENDER = CL_SAPUSER_BCS=>CREATE( L1_UNAME ).
    * Setting the sender
          CALL METHOD L_SEND_REQUEST->SET_SENDER
            EXPORTING
              I_SENDER = LR_SENDER.
    * E-Mail
       LOOP AT P_EADDR.
          TRANSLATE P_EADDR-LOW TO LOWER CASE.
          L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_EADDR-LOW ).
          CALL METHOD L_SEND_REQUEST->ADD_RECIPIENT
            EXPORTING
              I_RECIPIENT  = L_RECIPIENT
              I_EXPRESS    = 'U'
              I_COPY       = ' '
              I_BLIND_COPY = ' '
              I_NO_FORWARD = ' '.
           IF SY-subrc EQ 0.
              WRITE:/'** SUCCESS:  Email Sent to', p_eaddr-LOW COLOR COL_NORMAL.
            ELSE.
              WRITE:/'** ERROR: Failed to send Email to',p_eaddr-LOW COLOR COL_NEGATIVE .
            ENDIF.
          ENDLOOP.
    *Trigger E-Mail immediately
          L_SEND_REQUEST->SET_SEND_IMMEDIATELY( ' ' ).
          CALL METHOD L_SEND_REQUEST->SEND( ).
          COMMIT WORK.
        CATCH CX_DOCUMENT_BCS INTO L_BCS_EXCEPTION.
        CATCH CX_SEND_REQ_BCS INTO L_SEND_EXCEPTION.
        CATCH CX_ADDRESS_BCS  INTO L_ADDR_EXCEPTION.
      ENDTRY.
    *&      Form  PREPARE_ATTACHMENT
    FORM PREPARE_ATTACHMENT .
      FIELD-SYMBOLS: <LFS_TABLE>,    " Internal table structure
                     <LFS_CON>.      " Field Content
      DATA: L_TEXT TYPE CHAR1024.     " Text content for mail attachment
      DATA: L_CON TYPE STRING. "(50) TYPE c.        " Field Content in character format
      DATA: L_STR TYPE STRING,
            L_STR1 TYPE STRING.
      DATA: LS_SOLIX TYPE SOLIX.
    * Columns to be tab delimeted
      LOOP AT I_MARA ASSIGNING <LFS_TABLE>.
        DO.
          ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
                 TO <LFS_CON>.
          IF SY-SUBRC NE 0.
            CONCATENATE C_CR L_TEXT INTO L_TEXT.
    *        CONCATENATE l_str c_cr l_text INTO l_str.
    *        ls_solix-line = l_text.
    *        APPEND ls_solix TO i_attach.
            APPEND L_TEXT TO I_ATTACH.
            EXIT.
          ELSE.
            CLEAR: L_CON.
            MOVE <LFS_CON> TO L_CON.
            CONDENSE L_CON.
            IF SY-INDEX = 1.
              CLEAR: L_TEXT.
              MOVE L_CON TO L_TEXT.
            ELSE.
              CONCATENATE L_TEXT L_CON INTO L_TEXT
                 SEPARATED BY C_TAB.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    ** Columns to be tab delimeted
    *  LOOP AT I_MARC ASSIGNING <LFS_TABLE>.
    *    DO.
    *      ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
    *             TO <LFS_CON>.
    *      IF SY-SUBRC NE 0.
    *        CONCATENATE C_CR L_TEXT INTO L_TEXT.
    **        CONCATENATE l_str c_cr l_text INTO l_str1.
    *        LS_SOLIX-LINE = L_TEXT.
    *        APPEND LS_SOLIX TO I_ATTACH1.
    *        EXIT.
    *      ELSE.
    *        CLEAR: L_CON.
    *        MOVE <LFS_CON> TO L_CON.
    *        CONDENSE L_CON.
    *        IF SY-INDEX = 1.
    *          CLEAR: L_TEXT.
    *          MOVE L_CON TO L_TEXT.
    *        ELSE.
    *          CONCATENATE L_TEXT L_CON INTO L_TEXT
    *             SEPARATED BY C_TAB.
    *        ENDIF.
    *      ENDIF.
    *    ENDDO.
    *  ENDLOOP.
    *  i_attach1[] = i_attach[].
    ENDFORM.                    " PREPARE_ATTACHMENT

    Hi Sas,
    I have copied the code and executed and it is working fine. I'm getting the text attachement in the email.
    * Adding Attachment
          CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
            EXPORTING
              I_ATTACHMENT_TYPE    = 'TXT'          "  C_EXT   My change
              I_ATTACHMENT_SIZE    = L_SIZE
              I_ATTACHMENT_SUBJECT = 'MARA Details'
    *          i_att_content_hex    = i_attach[].
              I_ATT_CONTENT_TEXT   = I_ATTACH[].
    CONCATENATE i_mara-MATNR
                             i_mara-ERSDA
                             i_mara-ERNAM
                             i_mara-LAEDA
                   INTO   L_TEXT
                 SEPARATED BY '|'.

  • How to send e-mail with an attachment from remote database server.???

    Hi All,
    I have tried the simple mail sending and with the attachment using UTL_SMTP. But the problem is , it is sending the mail with attachment of the file name i give, it takes and creates that file and sends as attachment not from the actual file location. I am trying to attach the file which i stored in remote database server.
    The following code I tried. But not worked for attachment
    DECLARE
       v_From       VARCHAR2(80) := '[email protected]';
       v_Recipient  VARCHAR2(80) := '[email protected]';
       v_Subject    VARCHAR2(80) := 'test subject';
       v_Mail_Host  VARCHAR2(30) := 'pop3.somedomain.com';
       v_Mail_Conn  utl_smtp.Connection;
       crlf         VARCHAR2(2)  := chr(13)||chr(10);
    BEGIN
      v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
      utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
      utl_smtp.Mail(v_Mail_Conn, v_From);
      utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
      utl_smtp.Data(v_Mail_Conn,
        'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
        'From: '   || v_From || crlf ||
        'Subject: '|| v_Subject || crlf ||
        'To: '     || v_Recipient || crlf ||
        'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
        'Content-Type: multipart/mixed;'|| crlf ||
        ' boundary="-----SECBOUND"'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/html;'|| crlf ||
        'Content-Transfer_Encoding: 7bit'|| crlf ||
        crlf ||
        'some message text'|| crlf ||     -- Message body
        'more message text'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/html;'|| crlf ||
        ' name="Fund Authorization report"'|| crlf ||
        'Content-Transfer_Encoding: 8bit'|| crlf ||
        'Content-Disposition: attachment;'|| crlf ||
        ' filename="/usr/tmp/Test.html"'|| crlf ||
        crlf ||
        'HTML Attachment'|| crlf ||     -- Content of attachment
        crlf ||
        '-------SECBOUND--'               -- End MIME mail
      utl_smtp.Quit(v_mail_conn);
    EXCEPTION
      WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
        raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;How can I attach a file which is stored in database server and send it in a mail.
    Please someone help me in this.
    Thanks,
    Alaka.

    Try this code
    Regards Salim.
    CREATE OR REPLACE TRIGGER EmailOnServerErr AFTER SERVERERROR ON DATABASE
    DECLARE
       mail_conn       UTL_SMTP.connection;
       crlf            VARCHAR2(2) := chr(13)||chr(10);
       msg             VARCHAR2(32760);
       sid_name        VARCHAR2(16);
       bdump_dest      VARCHAR2(128);
       smtp_relay      VARCHAR2(32) := 'MyMailRelay';
       recipient_address  VARCHAR2(64) := '[email protected]';
       sender_address     VARCHAR2(64) := '[email protected]';
       mail_port       NUMBER := 25;
       log_file_handle UTL_FILE.FILE_TYPE;
       log_file_dir    VARCHAR2(256) := 'ERR_LOG_DIR';
       log_file_name   VARCHAR2(256) := 'OracleErrors.log';
       maxlinesize     NUMBER := 32767;
       session_rec     sys.v_$session%ROWTYPE;
       audit_rec       sys.dba_audit_trail%ROWTYPE;
       auditing        BOOLEAN;
       LinesOfSQL      BINARY_INTEGER;
       offending_sql   DBMS_STANDARD.ora_name_list_t;
       CURSOR bdump_cur IS
          SELECT TRIM(value)
          FROM v$parameter
          WHERE name = 'background_dump_dest'
       CURSOR sid_cur IS
          SELECT TRIM(instance_name)
          FROM v$instance
       CURSOR session_cur IS
          SELECT s.*
          FROM v$session s
          WHERE s.sid = dbms_support.mysid
       CURSOR audit_trail_cur(AUDSID IN NUMBER) IS
          SELECT *
          FROM dba_audit_trail
          WHERE sessionid = AUDSID
    BEGIN
       IF (USER = 'SYSTEM' OR USER = 'SYS') THEN
          -- Ignore this error
          NULL;
       ELSIF IS_SERVERERROR (1034) THEN
          -- Ignore this error
          NULL;
       ELSE
          -- get the sid
          OPEN sid_cur;
          FETCH sid_cur INTO sid_name;
          CLOSE sid_cur;
          -- get the location of the alert log
          OPEN bdump_cur;
          FETCH bdump_cur INTO bdump_dest;
          CLOSE bdump_cur;
          -- get the session information
          OPEN session_cur;
          FETCH session_cur INTO session_rec;
          CLOSE session_cur;
          -- get the audit_trail information if it exists
          OPEN audit_trail_cur(session_rec.audsid);
          FETCH audit_trail_cur INTO audit_rec;
          auditing := audit_trail_cur%FOUND;
          CLOSE audit_trail_cur;
          IF session_rec.program = 'MyProgram.exe' THEN
             NULL;  -- ignore actions from MyProgram - that's where I do maintenance
          ELSE
             -- compose the message
             msg := 'Subject: Oracle error '||' on '||sid_name||crlf;
             msg := msg||'To: '||recipient_address||crlf;
             msg := msg||'For more information see the alert log file located at:'||crlf;
             msg := msg||bdump_dest||'/alert_'||sid_name||'.log'||crlf;
             msg := msg||'or the error log file: $'||log_file_dir||'/'||log_file_name||crlf;
             msg := msg||'Error Time='||TO_CHAR(SYSDATE,'DD-Mon-YYYY HH24:MI:SS')||crlf;
             msg := msg||DBMS_UTILITY.FORMAT_CALL_STACK||crlf;
             LinesOfSQL := sql_txt(offending_sql);
             msg := msg||'Offending SQL is:'||crlf;
             FOR loop_counter IN offending_sql.FIRST..offending_sql.LAST
             LOOP
                msg := msg||offending_sql(loop_counter);
             END LOOP;
             msg := msg||crlf||'----- PL/SQL Error Stack -----'||crlf;
             msg := msg||DBMS_UTILITY.FORMAT_ERROR_STACK||crlf;
             msg := msg||'V$SESSION.SADDR='   ||session_rec.saddr   ||crlf;
             msg := msg||'V$SESSION.SID='     ||session_rec.sid     ||crlf;
             msg := msg||'V$SESSION.SERIAL#=' ||session_rec.serial# ||crlf;
             msg := msg||'V$SESSION.AUDSID='  ||session_rec.audsid  ||crlf;
             msg := msg||'V$SESSION.PADDR='   ||session_rec.paddr   ||crlf;
             msg := msg||'V$SESSION.USER#='   ||session_rec.user#   ||crlf;
             msg := msg||'V$SESSION.USERNAME='||session_rec.username||crlf;
             msg := msg||'V$SESSION.COMMAND=' ||session_rec.command ||crlf;
             msg := msg||'V$SESSION.OWNERID=' ||session_rec.ownerid ||crlf;
             msg := msg||'V$SESSION.TADDR='   ||NVL(session_rec.taddr   ,'Null')||crlf;
             msg := msg||'V$SESSION.LOCKWAIT='||NVL(session_rec.lockwait,'Null')||crlf;
             msg := msg||'V$SESSION.STATUS='  ||NVL(session_rec.status  ,'Null')||crlf;
             msg := msg||'V$SESSION.SERVER='  ||NVL(session_rec.server  ,'Null')||crlf;
             msg := msg||'V$SESSION.SCHEMA#=' ||session_rec.schema#||crlf;
             msg := msg||'V$SESSION.SCHEMANAME=' ||NVL(session_rec.schemaname,'Null')||crlf;
             msg := msg||'V$SESSION.OSUSER='     ||NVL(session_rec.osuser    ,'Null')||crlf;
             msg := msg||'V$SESSION.PROCESS='    ||NVL(session_rec.process   ,'Null')||crlf;
             msg := msg||'V$SESSION.MACHINE='    ||NVL(session_rec.machine   ,'Null')||crlf;
             msg := msg||'V$SESSION.TERMINAL='   ||NVL(session_rec.terminal  ,'Null')||crlf;
             msg := msg||'V$SESSION.PROGRAM='    ||NVL(session_rec.program   ,'Null')||crlf;
             msg := msg||'V$SESSION.TYPE='       ||NVL(session_rec.type      ,'Null')||crlf;
             msg := msg||'V$SESSION.SQL_ADDRESS='    ||session_rec.sql_address  ||crlf;
             msg := msg||'V$SESSION.SQL_HASH_VALUE=' ||NVL(TO_CHAR(session_rec.sql_hash_value) ,'Null')||crlf;
             msg := msg||'V$SESSION.PREV_SQL_ADDR='  ||session_rec.prev_sql_addr||crlf;
             msg := msg||'V$SESSION.PREV_HASH_VALUE='||NVL(TO_CHAR(session_rec.prev_hash_value),'Null')||crlf;
             msg := msg||'V$SESSION.MODULE='     ||NVL(session_rec.module              ,'Null')||crlf;
             msg := msg||'V$SESSION.MODULE_HASH='||NVL(TO_CHAR(session_rec.module_hash),'Null')||crlf;
             msg := msg||'V$SESSION.ACTION='     ||NVL(session_rec.action              ,'Null')||crlf;
             msg := msg||'V$SESSION.ACTION_HASH='||NVL(TO_CHAR(session_rec.action_hash),'Null')||crlf;
             msg := msg||'V$SESSION.CLIENT_INFO='||NVL(session_rec.client_info         ,'Null')||crlf;
             msg := msg||'V$SESSION.FIXED_TABLE_SEQUENCE='||NVL(TO_CHAR(session_rec.fixed_table_sequence),'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_OBJ#='  ||NVL(TO_CHAR(session_rec.row_wait_obj#)  ,'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_FILE#=' ||NVL(TO_CHAR(session_rec.row_wait_file#) ,'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_BLOCK#='||NVL(TO_CHAR(session_rec.row_wait_block#),'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_ROW#='  ||NVL(TO_CHAR(session_rec.row_wait_row#)  ,'Null')||crlf;
             msg := msg||'V$SESSION.LOGON_TIME='     ||NVL(TO_CHAR(session_rec.logon_time,'DD-Mon-YYYY HH24:MI:SS'),'Null')||crlf;
             msg := msg||'V$SESSION.LAST_CALL_ET='   ||NVL(TO_CHAR(session_rec.last_call_et)   ,'Null')||crlf;
             msg := msg||'V$SESSION.PDML_ENABLED='   ||NVL(session_rec.pdml_enabled   ,'Null')||crlf;
             msg := msg||'V$SESSION.FAILOVER_TYPE='  ||NVL(session_rec.failover_type  ,'Null')||crlf;
             msg := msg||'V$SESSION.FAILOVER_METHOD='||NVL(session_rec.failover_method,'Null')||crlf;
             msg := msg||'V$SESSION.FAILED_OVER='    ||NVL(session_rec.failed_over    ,'Null')||crlf;
             msg := msg||'V$SESSION.RESOURCE_CONSUMER_GROUP='||NVL(session_rec.resource_consumer_group,'Null')||crlf;
             msg := msg||'V$SESSION.PDML_STATUS='    ||NVL(session_rec.pdml_status    ,'Null')||crlf;
             msg := msg||'V$SESSION.PDDL_STATUS='    ||NVL(session_rec.pddl_status    ,'Null')||crlf;
             msg := msg||'V$SESSION.PQ_STATUS='      ||NVL(session_rec.pq_status      ,'Null')||crlf;
             IF auditing THEN
                msg := msg||'DBA_AUDIT_TRAIL.OS_USERNAME='  ||NVL(audit_rec.os_username,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.USERNAME='     ||NVL(audit_rec.username   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.USERHOST='     ||NVL(audit_rec.userhost   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.TERMINAL='     ||NVL(audit_rec.terminal   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.TIMESTAMP='    ||TO_CHAR(audit_rec.timestamp,'DD-Mon-YYYY HH24:MI:SS')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OWNER='        ||NVL(audit_rec.owner      ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OBJ_NAME='     ||NVL(audit_rec.obj_name   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ACTION='       ||audit_rec.action   ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ACTION_NAME='  ||NVL(audit_rec.action_name   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.NEW_OWNER='    ||NVL(audit_rec.new_owner     ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.NEW_NAME='     ||NVL(audit_rec.new_name      ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OBJ_PRIVILEGE='||NVL(audit_rec.obj_privilege ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SYS_PRIVILEGE='||NVL(audit_rec.sys_privilege ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ADMIN_OPTION=' ||NVL(audit_rec.admin_option  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.GRANTEE='      ||NVL(audit_rec.grantee       ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.AUDIT_OPTION=' ||NVL(audit_rec.audit_option  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SES_ACTIONS='  ||NVL(audit_rec.ses_actions   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_TIME='  ||NVL(TO_CHAR(audit_rec.logoff_time)  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LREAD=' ||NVL(TO_CHAR(audit_rec.logoff_lread) ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_PREAD=' ||NVL(TO_CHAR(audit_rec.logoff_pread) ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LWRITE='||NVL(TO_CHAR(audit_rec.logoff_lwrite),'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_DLOCK=' ||NVL(audit_rec.logoff_dlock  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.COMMENT_TEXT=' ||NVL(audit_rec.comment_text  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SESSIONID='    ||audit_rec.sessionid   ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ENTRYID='      ||audit_rec.entryid     ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.STATEMENTID='  ||audit_rec.statementid ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.RETURNCODE='   ||audit_rec.returncode  ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.PRIV_USED='    ||NVL(audit_rec.priv_used,'Null')||crlf;
             END IF;
             msg := msg||'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'||crlf||crlf;
             -- write the message to the error log file
             log_file_handle := UTL_FILE.FOPEN (log_file_dir, log_file_name, 'A',maxlinesize);
             UTL_FILE.PUT_LINE(log_file_handle,msg);
             UTL_FILE.FCLOSE(log_file_handle);
             -- send the message by Email
             mail_conn := UTL_SMTP.open_connection(smtp_relay, mail_port);
             UTL_SMTP.HELO(mail_conn, smtp_relay);
             UTL_SMTP.MAIL(mail_conn, sender_address);
             UTL_SMTP.RCPT(mail_conn, recipient_address);
             UTL_SMTP.DATA(mail_conn, msg);
             UTL_SMTP.QUIT(mail_conn);
          END IF; -- client_program = MyProgram.exe
       END IF;
    END;
    /

  • How to send a mail as .txt attachment ?

    Hi all,
    I got a requirement to write code for sending mail in oops.
    i have written code for .xls which is working fine. But requirement is to send the mail in the format of txt.
    i just only chnge the .xls to .txt where i can see the output properly in sap but problem is that i am unable to get the proper alignment. when i execute the report and see the output in sost i can see the attachment.i am downloading the attachment there only(Our server is not configured to get the mails directly) .So when i open the saved text file on my pc the output is appearing as follows...
    pernr nachn vorna
            0001 L0001 F0001
                0002 L0002 F0002
                   0003 L0003 F0003
                         0004 L0004 F0004...
    Where it should come in straight line as follows in my o/p code..
    pernr nachn vorna
    0001 L0001 F0001
    0002 L0002 F0002
    0003 L0003 F0003
    0004 L0004 F0004...
    i am puttin g my code ..please correct me where i am wrong .....waiting for your valuabel inputs..
    *& Report  ZGBTEST02
    REPORT  YSAS_MAIL2.
    *Changes done by sas
    *PARAMETERS: P_MAIL TYPE AD_SMTPADR OBLIGATORY, " G C by sas
    *P_MAIL1 TYPE AD_SMTPADR OBLIGATORY." G by sas
    TABLES: ADR6.
    SELECT-OPTIONS:P_EADDR FOR ADR6-SMTP_ADDR NO INTERVALS .
    *end of changes by sas
    DATA: I_GLT0 TYPE STANDARD TABLE OF GLT0.
    *DATA: I_pernr  TYPE STANDARD TABLE OF pa0002.  " MARA Entries
    DATA: BEGIN OF I_PERNR OCCURS 1 ,
    PERNR TYPE PA0002-PERNR,
    NACHN TYPE PA0002-NACHN,
    VORNA TYPE PA0002-VORNA,
    END OF I_PERNR..
    *      I_MARC  TYPE STANDARD TABLE OF MARC.  " MARC Entries
    DATA: L_TEXT  TYPE CHAR255.  " Text
    DATA: L_LINES TYPE I,
          L_SIZE  TYPE SOOD-OBJLEN.
    " Size of Attachment
    * Mail related
    DATA: I_CONTENT         TYPE   SOLI_TAB, " Mail content
          I_ATTACH          TYPE   SOLI_TAB, " Attachment
          I_ATTACH1         TYPE   SOLIX_TAB. " Attachment
    DATA: L_SEND_REQUEST    TYPE REF TO    CL_BCS,
                                                " E-Mail Send Request
          L_DOCUMENT        TYPE REF TO    CL_DOCUMENT_BCS,
                                                " E-Mail Attachment
          L_RECIPIENT       TYPE REF TO    IF_RECIPIENT_BCS,
                                                " Distribution List
          L_SENDER          TYPE REF TO    IF_SENDER_BCS,
                                                " Address of Sender
          L_UNAME           TYPE           SALRTDRCPT,
                                                " Sender Name(SY-UNAME)
          L_BCS_EXCEPTION   TYPE REF TO    CX_DOCUMENT_BCS,
                                                " BCS Exception
          L_ADDR_EXCEPTION  TYPE REF TO    CX_ADDRESS_BCS,
                                                " Address Exception
          L_SEND_EXCEPTION  TYPE REF TO    CX_SEND_REQ_BCS.
    " E-Mail sending Exception
    *Constants------------------------------------------------------------*
    CONSTANTS: C_TAB(1) TYPE C VALUE
               CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
                                         " Tab Character
               C_CR(1)  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF,
                                         " Line Feed for End-Of_line
               C_EXT    TYPE SOODK-OBJTP VALUE 'TXT'. " XLS Extension
    START-OF-SELECTION.
      SELECT PERNR NACHN VORNA  FROM PA0002 INTO CORRESPONDING FIELDS OF TABLE I_PERNR UP TO 20 ROWS.
    *select * from glt0 into table i_glt0.
    * Preparing body of the Mail
    *  MOVE 'SAP Material Master Records' TO L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
    *  CLEAR L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
    *  MOVE 'Thanks,' TO L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
    *  MOVE 'SAP MM' TO L_TEXT.
    *  APPEND L_TEXT TO I_CONTENT.
      MOVE '<BR>Attached is your HRIS report(s) generated from the Firm''s' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE ' Human Resources  Information System (SAP).' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE '<BR>  ' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
      MOVE '<BR>This is an automated report.' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    *        MOVE '<BR>  ' TO l_text.
    *        APPEND l_text TO i_content.
      MOVE '<BR>  ' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    *        MOVE '<BR>Please do not reply to this email' TO l_text.
    *        APPEND l_text TO i_content.
    *        MOVE '<BR>  ' TO l_text.
    *        APPEND l_text TO i_content.
      MOVE '<BR>Thank you.' TO L_TEXT.
      APPEND L_TEXT TO I_CONTENT.
    * Creates persistent send request
      TRY.
          L_SEND_REQUEST = CL_BCS=>CREATE_PERSISTENT( ).
    * Creating Document
          L_DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
                                        I_TYPE  = 'RAW'
                                        I_TEXT  = I_CONTENT[]
                                        I_SUBJECT = 'Automated HRIS (SAP) Report' ).
    DATA: W_PERNR LIKE I_PERNR.
    * Preparing contents of attachment with Change Log
          PERFORM PREPARE_ATTACHMENT.
          DATA: compressed like solisti1 occurs 10 with header line.
    DATA: decompressed like solisti1 occurs 10 with header line.
          CALL FUNCTION 'TABLE_COMPRESS'
    *   IMPORTING
    *     COMPRESSED_SIZE       =
                        TABLES
    *      in                    = eerec
                          in                    = i_attach
                          out                   = compressed.
          CALL FUNCTION 'TABLE_DECOMPRESS'
            TABLES
              in  = compressed
              out = decompressed.
          DESCRIBE TABLE decompressed LINES L_LINES.
    * Size to multiplied by 2 for UNICODE enabled systems
          L_SIZE = L_LINES * 2 * 255.
    * Adding Attachment
          CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
            EXPORTING
              I_ATTACHMENT_TYPE    = C_EXT
              I_ATTACHMENT_SIZE    = L_SIZE
              I_ATTACHMENT_SUBJECT = 'Hr Details'
    *          i_att_content_hex    = i_attach[].
              I_ATT_CONTENT_TEXT   = decompressed[].
    *      DESCRIBE TABLE I_MARC LINES L_LINES.
    * Size to multiplied by 2 for UNICODE enabled systems
    *      L_SIZE = L_LINES * 2 * 255.
    ** Adding Attachment
    *      CALL METHOD L_DOCUMENT->ADD_ATTACHMENT
    *        EXPORTING
    *          I_ATTACHMENT_TYPE    = C_EXT
    *          I_ATTACHMENT_SIZE    = L_SIZE
    *          I_ATTACHMENT_SUBJECT = 'MARC Details'
    *          I_ATT_CONTENT_HEX    = I_ATTACH1[].
    **          i_att_content_text   = i_attach1[].
    * Add document to send request
          CALL METHOD L_SEND_REQUEST->SET_DOCUMENT( L_DOCUMENT ).
          DATA:LR_SENDER TYPE REF TO IF_SENDER_BCS,
               LR_SEND TYPE REF TO CL_BCS.
    * Preparing the sender object
    *      LR_SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( sy-uname ).
          DATA: L1_UNAME TYPE SY-UNAME.
          L1_UNAME = SY-UNAME.
          LR_SENDER = CL_SAPUSER_BCS=>CREATE( L1_UNAME ).
    * Setting the sender
          CALL METHOD L_SEND_REQUEST->SET_SENDER
            EXPORTING
              I_SENDER = LR_SENDER.
    * E-Mail
          LOOP AT P_EADDR.
            TRANSLATE P_EADDR-LOW TO LOWER CASE.
            L_RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( P_EADDR-LOW ).
            CALL METHOD L_SEND_REQUEST->ADD_RECIPIENT
              EXPORTING
                I_RECIPIENT  = L_RECIPIENT
                I_EXPRESS    = 'U'
                I_COPY       = ' '
                I_BLIND_COPY = ' '
                I_NO_FORWARD = ' '.
            IF SY-SUBRC EQ 0.
              WRITE:/'** SUCCESS:  Email Sent to', P_EADDR-LOW COLOR COL_NORMAL.
            ELSE.
              WRITE:/'** ERROR: Failed to send Email to',P_EADDR-LOW COLOR COL_NEGATIVE .
            ENDIF.
          ENDLOOP.
    *Trigger E-Mail immediately
          L_SEND_REQUEST->SET_SEND_IMMEDIATELY( ' ' ).
          CALL METHOD L_SEND_REQUEST->SEND( ).
          COMMIT WORK.
        CATCH CX_DOCUMENT_BCS INTO L_BCS_EXCEPTION.
        CATCH CX_SEND_REQ_BCS INTO L_SEND_EXCEPTION.
        CATCH CX_ADDRESS_BCS  INTO L_ADDR_EXCEPTION.
      ENDTRY.
    *&      Form  PREPARE_ATTACHMENT
    FORM PREPARE_ATTACHMENT .
      FIELD-SYMBOLS: <LFS_TABLE>,    " Internal table structure
                     <LFS_CON>.      " Field Content
      DATA: L_TEXT TYPE CHAR1024.     " Text content for mail attachment
      DATA: L_CON TYPE STRING. "(50) TYPE c.        " Field Content in character format
      DATA: L_STR TYPE STRING,
            L_STR1 TYPE STRING.
    *data: w_pernr type TABLE OF I_PERNR.
      DATA: LS_SOLIX TYPE SOLIX.
    *  CONCATENATE 'PERNR' 'FIRST NAME' 'Last Name' C_CR INTO L_TEXT SEPARATED BY '|'.
    *  append l_text to i_attach.
    *  clear l_text.
    * Columns to be tab delimeted
      LOOP AT I_PERNR ASSIGNING <LFS_TABLE>.
        DO.
          ASSIGN COMPONENT SY-INDEX OF STRUCTURE <LFS_TABLE>
                 TO <LFS_CON>.
          IF SY-SUBRC NE 0.
            CONCATENATE C_CR L_TEXT INTO L_TEXT.
    *        CONCATENATE l_str c_cr l_text INTO l_str.
    *        ls_solix-line = l_text.
    *        APPEND ls_solix TO i_attach.
            APPEND L_TEXT TO I_ATTACH.
            EXIT.
          ELSE.
            CLEAR: L_CON.
            MOVE <LFS_CON> TO L_CON.
            CONDENSE L_CON.
            IF SY-INDEX = 1.
              CLEAR: L_TEXT.
              MOVE L_CON TO L_TEXT.
            ELSE.
              CONCATENATE L_TEXT L_CON INTO L_TEXT
                 SEPARATED BY C_TAB.
            ENDIF.
          ENDIF.
        ENDDO.
      ENDLOOP.
    *  i_attach1[] = i_attach[].
    ENDFORM.                    " PREPARE_ATTACHMENT
    Please if any one having 6.0 version please upload it and see..
    Regards
    Sas

    Hi ,
    Did you downloaded from  SOST  using the display icon and inside that 4th tab for attachment ....
    and see?
    Regards
    sas
    pS: THE FIRST page is not allowing the spaces in sdn...
    i am getting o/p as
    pernr vochn norna
    .........0001 f0001 l0001
    .................0002 F0002 L0002
    .......................0003 F0003 L0003.....
    Please remove dots and understand that is the o/p i am getting in my presenation file
    i just expecting the o/p as told earlier..
    Regards
    sas

  • When notification is put in process, How to send automatic mail

    Hi All,
    When the Maintenance notification is put in process, a mail has to be sent with the notification Number to Business / Mainteannce people's mail address. Is this possible through configurations,action box, workflow or by means of exit ???
    Please let me know your solutions.
    Thanks

    Hi Rahul
    I dont think you can do it in Action Box.
    In action box you define the functions, with which you can generate tasks or activities (known as supplementary actions) for a notification. These functions should be defined using a key and a label. They are assigned to a notification type, and are available at header level when processing notifications. When the function is called up, the system copies the task or activity defined into the notification.
    Check it out and revert back
    - Pithan

  • How to send Java Mail with EXCEL attachment?

    I tried the following:
    ByteArrayDataSource bs = new ByteArrayDataSource (is, "application/excel");
    as my datasource (all other apis are fine)
    But when I send this message with this datasource as attachment,I get a ParseException with the VM complaining about malformed headers.
    Please help

    Exactly when do you get the ParseException, and what's the message
    with the exception?
    BTW, "application/excel" is not the correct MIME type for Microsoft Office
    Excel files. The correct MIME type is "application/vnd.ms-excel".
    http://www.iana.org/assignments/media-types/application/vnd.ms-excel

  • How to send a 'filename' and a byte representation of a file

    Hey
    I have this very simpel program, the logic is.. Client sends a file to a server which stores the file... VERY SIMPEL!
    But what i wanna do is to send the filename as well, so the server can name the file dynamically based on the source file received
    My code looks like this now..
    Server code
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package serverreceivefile;
    import java.io.*;
    import java.net.*;
    * @author Maul
    public class ServerReceiveFile {
         * @param args the command line arguments
        public static void main(String[] args) throws IOException {
            System.out.println("Server is starting../");
            //Create a server socket that listens for incoming connection
            //request on port 10000
            ServerSocket ss = new ServerSocket(10000);
            while(true){
             // Listen for incoming connection requests from client
             // programs, establish a connection, and return a Socket
             // object that represents this connection.
                Socket s = ss.accept();
                System.out.println("Accepting connection.../");
                // Start a thread to handle connection
                new ServerThread(s).start();
    class ServerThread extends Thread{
        private Socket s;
        ServerThread(Socket s){
            this.s = s;
        @Override
        public void run(){
            BufferedInputStream bs = null;
            BufferedOutputStream bos = null;
            try {
              // Create an input stream reader that chains to the socket's
              // byte-oriented input stream. The input stream reader
              // converts bytes read from the socket to characters. The
              // conversion is based on the platform's default character
              // set.
              bs = new BufferedInputStream(s.getInputStream());
              bos = new BufferedOutputStream(new FileOutputStream("filecopy.txt"));
              int i = 0;
              while((i = bs.read()) != -1){
                  bos.write(i);
              bs.close();
              bos.close();
              s.close();
              } catch (IOException ie){
            System.exit(0);
    }Client code
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package serverclientsendfile;
    import java.io.*;
    import java.net.*;
    * @author Maul
    public class ServerClientSendFile {
         * @param args the command line arguments
        public static void main(String[] args) throws FileNotFoundException
            String host = "localhost";
            BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
                    "file.txt"));
            Socket s = null;
            try {
                s = new Socket(InetAddress.getByName(host), 10000);
                // Create an input stream reader that chains to the socket's
                // byte-oriented input stream. The input stream reader
                // converts bytes read from the socket to characters. The
                // conversion is based on the platform's default character
                // set.
                BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
                int c;
                while((c = bis.read()) != -1){
                    bos.write(c);
                bis.close();
                bos.close();
            } catch (IOException ie){
    }As you can see the server 'hard codes' the filename of the received file from the client..

    Hi DJHingapus,
    If you don't want to build a dialog scenario between client and server, you may use a fixed length header which holds the name of the file to send. The stream will be composed with the header immediately followed by the binaries of the file.

  • How to send a request and get a response through xml

    How to send a request and get a response through xml files?

    This is the code that works for me. Hope you find it useful.
         public static String sendHttpGetRequest(String endpoint, String requestParameters){
              String result = null;
              // Send a GET request to the servlet
              try{
                   // Send data
                   String urlStr = endpoint;
                   if (requestParameters != null && requestParameters.length () > 0){
                        urlStr += "?" + requestParameters;
                   URL url = new URL(urlStr);
                   HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                   conn.setRequestProperty("Accept", "application/xml");
                   // Get the response
                   BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                   StringBuffer sb = new StringBuffer();
                   String line;
                   while ((line = rd.readLine()) != null){
                        sb.append(line);
                   rd.close();
                   result = sb.toString();
              } catch (Exception e){
                   e.printStackTrace();
              return result;
         }

  • How can scripts and  smart forms send to mail and pdf?

    HI i want to know how script and smartforms will send to mail and pdf formates>?

    Dear Anees ,
                       Pleas pass on the parameter in itcpo - (getotf  ) structure while calling OPEN_FORM as 'X' .
    I have answered it in detail in your earlier post .
    also giving below sample program for sending SAPSCRIPT as PDFattachment in email  :
    REPORT zsapscript_pdf_via_mail MESSAGE-ID zvele LINE-SIZE 68
    NO STANDARD PAGE HEADING.
    TABLES: itcpo.
    Open your usual sapscript specifying that the output will be OTF
    itcpo-tdgetotf = 'X'.
    CALL FUNCTION 'OPEN_FORM'
    EXPORTING
    device = 'PRINTER'
    dialog = ''
    form = '............'
    language = sy-langu
    options = itcpo
    EXCEPTIONS
    canceled = 1
    device = 2
    form = 3
    options = 4
    unclosed = 5
    OTHERS = 6.
    CALL FUNCTION 'WRITE_FORM'
    EXPORTING
    window = '............'
    element = '............'
    EXCEPTIONS
    window = 1
    element = 2.
    DATA: BEGIN OF t_otfdata OCCURS 0.
    INCLUDE STRUCTURE itcoo.
    DATA: END OF t_otfdata.
    Closing the Sapscript, we save data (OTF) in a table
    CALL FUNCTION 'CLOSE_FORM'
    TABLES
    otfdata = t_otfdata
    EXCEPTIONS
    unopened = 1
    bad_pageformat_for_print = 2
    send_error = 3
    spool_error = 4
    OTHERS = 5.
    DATA: len_in LIKE sood-objlen,
    len_out LIKE sood-objlen.
    DATA: BEGIN OF t_pdfdata OCCURS 0.
    INCLUDE STRUCTURE solisti1.
    DATA: END OF t_pdfdata.
    DATA: BEGIN OF t_otfdata2 OCCURS 0.
    INCLUDE STRUCTURE solisti1.
    DATA: END OF t_otfdata2.
    Move OTF data to another table with lenght 255
    LOOP AT t_otfdata.
    CONCATENATE t_otfdata-tdprintcom t_otfdata-tdprintpar INTO t_otfdata2.
    APPEND t_otfdata2.
    ENDLOOP.
    Convert OTF format to PDF
    CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
    EXPORTING
    format_src = 'OTF'
    format_dst = 'PDF'
    devtype = 'PRINTER'
    FUNCPARA =
    len_in = len_in
    IMPORTING
    len_out = len_out
    TABLES
    content_in = t_otfdata2
    content_out = t_pdfdata
    EXCEPTIONS
    err_conv_failed = 1
    OTHERS = 2.
    Download on local directory
    *CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE = len_out
    FILENAME = 'c:\test.pdf'
    FILETYPE = 'BIN'
    TABLES
    data_tab = t_pdfdata.
    Mail settings
    DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
    DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
    DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINe.
    DATA: doc_chng LIKE sodocchgi1.
    DATA righe_attachment TYPE i.
    DATA righe_testo TYPE i.
    DATA z_email(80) TYPE c.
    Receivers parameters
    SELECT-OPTIONS: s_email FOR z_email LOWER CASE NO INTERVALS.
    PARAMETERS rec_type LIKE reclist-rec_type
    DEFAULT 'U'. " type of sending address
    CLEAR: reclist, reclist[],
    objhead, objhead[],
    objtxt, objtxt[],
    objbin, objbin[],
    objpack, objpack[].
    Attachment filling
    LOOP AT t_pdfdata.
    objbin-line = t_pdfdata.
    APPEND objbin.
    ENDLOOP.
    DESCRIBE TABLE objbin LINES righe_attachment.
    Text filling
    objtxt = 'Testo della Mail - Riga 1'.APPEND objtxt.
    objtxt = 'Testo della Mail - Riga 2'.APPEND objtxt.
    objtxt = 'Testo della Mail - Riga n'.APPEND objtxt.
    DESCRIBE TABLE objtxt LINES righe_testo.
    Other filling
    doc_chng-obj_name = 'URGENT'.
    doc_chng-expiry_dat = sy-datum + 10.
    doc_chng-obj_descr = 'Prova invio Mail con PDF'.
    doc_chng-sensitivty = 'O'.
    doc_chng-doc_size = righe_testo * 255.
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = righe_testo.
    objpack-doc_type = 'RAW'.
    APPEND objpack.
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 1.
    objpack-body_start = 1.
    objpack-body_num = righe_attachment.
    objpack-doc_type = 'PDF'.
    objpack-obj_name = 'TEST'.
    objpack-obj_descr = 'File.pdf'.
    objpack-doc_size = righe_attachment * 255.
    APPEND objpack.
    Receivers filling
    LOOP AT s_email WHERE sign = 'I'
    AND option = 'EQ'
    AND NOT ( low IS initial ).
    CLEAR reclist.
    IF sy-tabix > 1.
    reclist-copy = 'X'.
    ENDIF.
    reclist-receiver = s_email-low.
    IF rec_type IS INITIAL.
    reclist-rec_type = 'U'. " Internet e-mail
    ELSE.
    reclist-rec_type = rec_type.
    ENDIF.
    reclist-notif_del = 'X'. " request delivery notification
    reclist-notif_ndel = 'X'. " request not delivered notification
    APPEND reclist.
    ENDLOOP.
    Mail Send
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = doc_chng
    put_in_outbox = 'X'
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    OBJECT_PARA =
    OBJECT_PARB =
    receivers = reclist
    CONTENTS_HEX =
    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

  • 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 e-mail notification automatically when a record is inserted?

    Dear All,
    Could anyone kindly tell me how to send e-mail notification automatically when a record is inserted through a form in Oracle Portal Release 2?
    Regards,
    Ridwan.

    Hi,
    If you are writing a form on a table then you can call the mail API from a database trigger on the table. If it is a form on a procedure, you can make the email call from the procedure. To know more about sending mails from plsql go to
    http://www.quest-pipelines.com/newsletter-v2/smtp.htm
    Thanks,
    Sharmila

  • 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 an email with an attachment to the customers email address.

    Hi friends,
    How to send an email with an attachment to the customers email address.
    the attachment will be in doc format.
    Having an Header
    the data which i am sending must be in a TABLE format
    with 5 columns.
    and each column must have a column heading
    Please guide me.
    Thanks in Advance,
    Ganesh.

    *& Report  ZEMAIL_ATTACH                                               *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver .
    *Here get the values of mail from the table adn6 for the customer address.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    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,
    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'
                                          'DOC'
                                          '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
       UP TO 10 ROWS
        FROM ekpo
        INTO 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'
             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
               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
    regards,
    venkat.

Maybe you are looking for