Sending a file using UTL_HTTP

I would like to send a file to a specific URL using UTL_HTTP by doing a HTTP multi-part POST. Does anyone know if / how this can be done?
Marc

DECLARE
l_mailhost VARCHAR2(64) := 'mail.mycompany.com';
l_from VARCHAR2(64) := '[email protected]';
l_subject VARCHAR2(64) := 'Test Mail';
l_to VARCHAR2(64) := '[email protected]';
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn := UTL_SMTP.open_connection(l_mailhost, 25);
UTL_SMTP.helo(l_mail_conn, l_mailhost);
UTL_SMTP.mail(l_mail_conn, l_from);
UTL_SMTP.rcpt(l_mail_conn, l_to);
UTL_SMTP.open_data(l_mail_conn);
UTL_SMTP.write_data(l_mail_conn, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || Chr(13));
UTL_SMTP.write_data(l_mail_conn, 'From: ' || l_from || Chr(13));
UTL_SMTP.write_data(l_mail_conn, 'Subject: ' || l_subject || Chr(13));
UTL_SMTP.write_data(l_mail_conn, 'To: ' || l_to || Chr(13));
UTL_SMTP.write_data(l_mail_conn, '' || Chr(13));
FOR i IN 1 .. 10 LOOP
UTL_SMTP.write_data(l_mail_conn, 'This is a test message. Line ' || To_Char(i) || Chr(13));
END LOOP;
UTL_SMTP.close_data(l_mail_conn);
UTL_SMTP.quit(l_mail_conn);
END;
/

Similar Messages

  • How to send a file using IOCP?

    When using blocking sockets, all I had to do to send a file was to open the file and loop through it and send it in chunks.
    But I find sending a file using overlapped sockets to be more challenging. I can think of the following approach to do it:
    I open the file and send the first chunk, and I keep track of the file handle and file position.
    Now when I get a completion packet indicating that some data has been sent, I check to see if the socket is currently in the process of sending a file, and if it is, I retrieve the file handle and file position and send the next chunk.
    I repeat step 2 until I reach the last chunk in the file, and then I close the file.
    Is this approach correct?
    Note: I don't want to use TransmitFile().

    This approach is more or less correct, but maybe you'd have to know some more things.
    If send "returns" it means, that you buffer has been copied into the internal buffer of system or the network interface card or whatever... in general it means, that you can free/reuse the buffer you have used, but it doesn't mean, that the data
    has been delivered (it does not even mean it has been sent already).
    That's why I'm normally using some flow-control (messages from the receiver) to verify the real data flow.
    The next point is, that you shouldn't read from the file only after you got the ok that the first chunk has been sent. You should read the data as soon as possible so that you can respond much quicker to a send-complete-message. I'd recommend to send using
    multiple buffers.
    Rudolf

  • Sending empty files using SFTP Adapter

    I am trying to send empty files using SFTP adapter. The interface has to send the file whether its empty file or containing data using SFTP adapter. I am using BizTalk Server 2013 R2. Is it a bug or the hotfix is already there for this issue.

    The issue here is not your SFTP not able to send 0KB files, but the file receive adapter that is receiving the file. The file adapter deletes 0 KB files and doest not transmit it further.
    If u have a ftp receive for example you should be able to send 0KB files.
    If u have a custom file receive adapter , is it handling 0KB files ?
    Regards <br/> When you see answers and helpful posts,<br/> please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

  • Sending a File Using DataGram Sockets

    I writting one java program that can be used to transfer a file from one computer to another computer.
    I wrote using Sockets.
    But i want to do that using DatagramSockets. Can we send a file using DataGramSockets?
    Please reply soon.

    You can use DataGram but it is harder.
    One issue is you need to retransmit missing packets. This means you need to keep track of which packets have been sent and be able to send missing ones again.
    If Socket work for you why do you want to use DataGrams

  • Send A file Using JMS

    I want to send a file Using JMS.. and want to have
    These Details in the message that send.
    Receivers IP address & The file
    That mean I want to send a File from one client to another client Using a Queue
    Can Anyone help me to solve this problem
    thanks

    Read the file then use a JMS BytesMessage or TextMessage. Add your own JMS header for the recievers ip and any other info you want to annotate the message with.
    Watch out for character encoding and max file size problems.
    If your client / server are not on the same network you're likely to run into firewall issues.
    Don't kid yourself that this will be a transactional solution.
    Assumes both clients are Java (JMS headers are a pain to read otherwise)

  • File format while sending a file  using FTP Process

    Hi,
    I am facing a formatting problem when i send a file from SAP application server to a different sever using FTP process.
    The problem is like this:
    Lets say I have a file with 10 records on the application server. When i am downloading this file to a pc, the file is showing 10 lines.
    But when i open the same file on the other server it is showing 10 records as 1 line.
    The file i am sending is a text file.(ex: acc_payable.txt)
    If i open the same file on the other server using word pad it is showing 10 records in 10 different lines.
    I want the file to be opened using notepad and want to see the each record in a different line
    Can anybody help me on this issue
    Regards,
    Radhakrishna

    Another stab at "simplest": can you avoid embedding
    newline characters in the strings
    your write and reply on PrintWriter's
    println() methods instead?But, if I understand the OP, this will cause the same problem. He is running on Unix but wants to generate a DOS type eol. The println() method will use the OS default; therefore, he needs to explicitly specify the DOS eol.

  • How to send large files using web service

    hello everyone,
    I am new to this forum, so please pardon me if I post some silly problem...
    I have created one service which sends file when client (jsp) request it. I am using JBOSS as my server. purpose of this application is when client request some fle then service will send this file... and most of the time we need to send only pdfs and ppts...
    Problem is, this service sends txt, java files easily of any size but when i tried sending PDF, PPT then i got xml.SAXParseException.......
    I thought this error is because of some characters, but how to fix it....
    I am working on Linux.
    code snippet is:
    import java.io.*;
    public class MyHelloService
    public String file_size (String name)
         String s = new String("");
    byte[] sendata1=new byte[100];
         try
              System.out.println("name recived is :::::::::::"+name);
              FileInputStream in=new FileInputStream(name);
              int size=0;
              size=in.available();
              System.out.println("FILE SIZE IS:::::"+size);
              byte[] sendata11=new byte[size];
              i=in.read(sendata11);
              System.out.println(new String(sendata11));
              s=new String(sendata11);
         catch(Exception e)
                   System.out.println("EXCEPTION IN JWS:::"+e);
                   s=new String("nofilefounderror");
         return s;
    pls tell me what am i doing wrong ad how to fix this?
    and one more thing can i send byte array from a web service as i tried but couldnt do that... so i am reading everything in a single byte array and then converted to string.....
    is it possibel to send file in a chunk?if yes, how to do that?
    waiting for the reply..... pls reply as soon as possible....
    Rashi

    hi,
    I am sending file from server to client i.e client will request for a file and service will send it back....... no socket connection is there...I am using JBOSS and apache axis.
    pls help me out.....
    Rashi

  • How to send A file using Webservice?

    I heard about webservice when I read through XML...
    It a bit like XML cannot show off it strength without webservice...lol
    What is webservice? What library should I use to send a file from server to client using webservice?
    Webservice is Quite new for me. Any expert here can direct me to the tutorial link that can teach me how to use webservice?
    I go through some code :
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://namespaces.cafeconleche.org/xmljava/ch2/"
    xmlns="http://namespaces.cafeconleche.org/xmljava/ch2/"
    elementFormDefault="qualified">What is xmlns? Is webservice can run it at localhost? My house don't have internet. :(
    Thank....

    to learn webservice..you can try these samples...
    http://www.csd.abdn.ac.uk/~bscharla/teaching/CS5302/practicals/practical8.shtml

  • How to send Excel File using file adapter

    Hello,
    Please could you tell how i can send an excel file using the file adpater?
    thank you.

    Hi hassiba ,
    If u want to doc on creating modules just check the wonderful document.
    How To Create Modules for the J2EE Adapter Engine at service.sap.com. It will clear all the basics of creating Adapter module.
    https://websmp102.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000582377&
    Thanks ,
    sekhar.

  • Sending/receiving files using SFTP

    Hi,
    Is there a way to use the Secure File Transfer Protocol (SFTP) in ABAP to send/receive files?
    I already used the FTP functionality from the function group SFTP, but I'm honestly not sure whether ABAP also handles the secure version of FTP.
    If there is this functionality, please provide me the necessary function modules, ...
    Thanks in advance
    Bye,
    Timo

    FTP functionality woks fine in ABAP. Below is some code which can be used for FTP access to send/receive files.
    Initially, get values for the below fields
      DATA: l_user(30) TYPE c VALUE <userid>,
            l_pwd(30)  TYPE c VALUE <password>,
            l_host(64) TYPE c VALUE <host string>,
      DATA: l_slen     TYPE i,
            l_error,
            l_pwd(30)  TYPE c.
      CONSTANTS: c_dest TYPE rfcdes-rfcdest VALUE 'SAPFTP',
                 c_key  TYPE i              VALUE 26101957.
    connect to ftp server
      l_pwd = p_pwd.
      l_slen = STRLEN( l_pwd ).
      CALL FUNCTION 'HTTP_SCRAMBLE'
        EXPORTING
          SOURCE      = l_pwd
          sourcelen   = l_slen
          key         = c_key
        IMPORTING
          destination = l_pwd.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text = 'Connect to FTP Server'.
      CALL FUNCTION 'FTP_CONNECT'
        EXPORTING
          user            = l_user
          password        = l_pwd
          host            = l_host
          rfc_destination = c_dest
        IMPORTING
          handle          = w_hdl
        EXCEPTIONS
          OTHERS          = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR : w_outfile, w_file_count.
    concatenate <directory> <filename> to field.
    MOVE field to w_outfile.
    PERFORM download_to_ftp TABLES <int'table>
                            USING w_outfile.
    FORM download_to_ftp TABLES it_tab
                         USING l_string TYPE char64.
      CALL FUNCTION 'FTP_R3_TO_SERVER'
        EXPORTING
          handle         = w_hdl
          fname          = l_string
          character_mode = 'X'
        TABLES
          text           = it_tab[]
        EXCEPTIONS
          tcpip_error    = 1
          command_error  = 2
          data_error     = 3
          OTHERS         = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                RAISING invalid_output_file.
      ENDIF.
    Above is used to send.
    For receiving use
      CALL FUNCTION 'FTP_SERVER_TO_R3'
        EXPORTING
          handle         = w_hdl
          fname          = l_string
          character_mode = 'X'
        TABLES
          text           = it_tab[]
        EXCEPTIONS
          tcpip_error    = 1
          command_error  = 2
          data_error     = 3
          OTHERS         = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                RAISING invalid_output_file.
      ENDIF.
    Hope this will help U.
    Pl. award appropriate points.

  • How to send TDMS file using TCP/IP

    Hi,
    I'm working with a cRIO-9025, chassis cRIO-9118 and NI 9239 module.
    I've done an acquisition (voltage) where data is in 1D Wfm SGL. I've saved this data using a TDMS file, but now I want to send this file to an other computer (in this case mine) because the file is stored in the target. To do that I've implemented this example:
    http://zone.ni.com/devzone/cda/epd/p/id/2842#0requirements
    The problem is that the tdms file is created but it hasn't any data. I attach the image of the program. The program is done in other project (not which I use to make acq) to make it easy and then implement it when it works.
    *The name file in the client is not used because I had a conflict with path.
    What I'm looking for is make an acquisition of 10 minutes every 30 minutes and then send this data to an other computer (or others). I'm not sure if it's the best way, maybe is better to send data at the same time as the acquisition is being done, but my theacher told me that is easier if I send the file when acquisition has finished. To make acq I use FPGA and RT.
    I would appreciate your help. Thanks!!
    Solved!
    Go to Solution.

    I believe the FTP VIs are built into LabVIEW 2011SP1 - I have the VI present, but I could have installed the internet toolkit (don't know).
    Look in the following location:   Function Palette -> Connectivity -> Internet -> FTP
    You're really looking for the VI named, "FTP Get File.vi".  What this VI does is contacts an FTP server and requests a file from it.  If your files are on the target, and you know the filename that will be created (such as files created in a sequence) you can request the file from the target and have them copied to the local machine (Windows).  RT cannot "push" files to the Windows side unless you have an FTP server (like FileZilla Server) running on the Windows host.
    It's a very simple one-VI solution.  You specify host (the IP Address of the target you're pulling files from), the remote path for the file (for instance if the file is located in c:\ni-rt\data\myfile.zip then that's what you put as the remote path of the file), the local path for the file (where you want the file copied to, along with the name of the file, such as c:\mydir\myfile.zip), the username to log into the FTP server with (default is 'anonymous') and the password to use (default is an empty string).  The importan thing to note is whether to use a binary transfer or not - if the file is a text file, no binary transfer needed; if the file is a binary file then you get better results using a binary transfer - I prefer to always use binary transfers, as non-binary transfers actually "interpret" and "convert" text information in the files.
    -Danny

  • To send attachment file using SMTP

    Hi,
    Can anybody help me to send an attachment file using SMTP?
    Regards,
    Rakesh

    do a search at asktom.oracle.com for javamail
    javamail is an api provided by sun (for free!), which allows you to send attachements and much more.
    greetings
    Freek D
    Hi,
    Can anybody help me to send an attachment file using SMTP?
    Regards,
    Rakesh

  • How to send a file using RMI

    hello,,
    I do one program using RMI that shoud transfer a file.. I compiles and no errors .while i am trying to execute this program i found some exception .
    rmiUnmarshalling exception and writeAborted Exception.
    ////Server.java
    import java.rmi.*;
    import java.rmi.server.*;
    import java.io.*;
    public class Server extends UnicastRemoteObject implements serverInterface
         private InputStream in;
         String filename;     
         public Server(String filename) throws RemoteException
              this.filename = filename;          
         public InputStream send() throws RemoteException
              try
                   in = new FileInputStream(filename);
                   int c;
                   while((c = in.read()) != -1)
                        System.out.println((char)c);
              catch(Exception ex)
                   System.out.println("Exception in impl : "+ex);
              return in;
         public static void main(String arg[])
              try
                   Naming.rebind("Server" , new Server("E:\\muthukumar\\RMI\\files\\interinter.java"));
                   System.out.println("Server is ready");
              catch(Exception e)
                   System.out.println("Exception in server : "+e);
    /// serverInterface.java
    import java.rmi.*;
    import java.io.*;
    public interface serverInterface extends Remote
         public InputStream send() throws RemoteException;
    ///Client.java
    import java.rmi.*;
    import java.rmi.server.*;
    import java.io.*;
    class Client
         public static void main(String arg[])
              try
                   serverInterface inter= (serverInterface)Naming.lookup("//localhost/Server");
                   InputStream in = inter.send();
                   int c;     
                   while((c = in.read()) != -1)
                        System.out.println((char)c);
              catch(Exception e)
                   System.out.println("Exception in client : "+e);
    please help me...
    thanks in advance..
    regards,
    Muthukumar

    If you know the file is too large to send as one chunk, then call different methods where you have a method to start saving the file then a method that saves chunks at a time and then a close when you're done. Otherwise, you could probably open a socket stream and have a reader on the client side and a writer on the server side.
    There are probably better ways to transfer files for sure. RMI is Remote Method Invocation similar to a Windows RPC (Remote Procedure Call) so that you can run some code on one machine from another. Streams and sockets are probably better for transfer. Another way you could do it is to use RMI to start up a socket listener like, but not limited to, FTP and then send the file through that API and then you could use RMI to stop the listener when you're done so it is only available when you need it. Even easier is to just have an FTP server running and transfer the file with the API. You can even use FTPS and you don't have to bother with the encryption to protect the data over the net.

  • Help required regarding sending jar files using bluetooth

    I want to send jar file from Nokia 7610 (S60), or any other phone for that matter, to any other phone using bluetooth. The problem is that, when I look at the options available for the jar file (which is saved in the Inbox), the send option is not visible.
    I looked at the previous postings on this topic. Is it due to "Closed Content List" (CCL)??? What are the possible workarounds, other than using getResourceAsStream or some software like FExplorer???
    Also, this problem is not encountered in Sony Ericsson phones. Plz help regarding the same...

    Hi,
    You might wanna look take a look in the JSR 82 Specifications. There is a method like agent.startInquiry(); that starts a search for nearby BT devices. All you have to do is place each found device in an array of type Vector.
    It would have been easier if your code or a snippet of it was available to see what the problem was.
    Rambo.
    PS: A client application application starts a connection on a server application. Where you put them is up to you.

  • Sending multiple files using one socket

    Hi guys
    I'm working on a simple app that sends multiple files over LAN or I-NET. The problem is that the app run seems to be non-deterministic. I keep getting this error on the client side:
    java.io.UTFDataFormatException: malformed input around byte 5
            at java.io.DataInputStream.readUTF(Unknown Source)
            at java.io.DataInputStream.readUTF(Unknown Source)
            at service.DownloadManager.storeRawStream(DownloadManager.java:116)
            at service.DownloadManager.downloadFiles(DownloadManager.java:47)
            at manager.NetworkTransferClient$1.run(NetworkTransferClient.java:104)The byte position changes every time I run a transfer. The error is caused by this line: String fileName = in.readUTF(); Here's the complete code:
    Client
    private void storeRawStream() {                               
            try {
                FileOutputStream fileOut;                       
                int fileCount = in.readInt();           
                for(int i=0; i<fileCount; i++) { 
                    byte data[] = new byte[BUFFER];
                    String fileName = in.readUTF();               
                    fileOut = new FileOutputStream(new File(upload, fileName)); 
                    long fileLength = in.readLong();                                 
                    for(int j=0; j<fileLength / BUFFER; j++) {
                        int totalCount = 0;
                        while(totalCount < BUFFER) {                       
                            int count = in.read(data, totalCount, BUFFER - totalCount);
                            totalCount += count;                 
                        fileOut.write(data, 0, totalCount);
                        fileOut.flush();
                        bytesRecieved += totalCount;                                  
                    // read the remaining bytes               
                    int count = in.read(data, 0, (int) (fileLength % BUFFER));                                        
                    fileOut.write(data, 0, count);              
                    fileOut.flush();
                    fileOut.close();      
                    transferLog.append("File " + fileName + " recieved successfully.\n");  
            } catch (Exception ex) {
                ex.printStackTrace();
        }Server
    public void sendFiles(File[] files) throws Exception {
            byte data[] = new byte[BUFFER];
            FileInputStream fileInput;                                       
            out.writeInt(files.length);              
            for (int i=0; i<files.length; i++) {   
                // send the file name
                out.writeUTF(files.getName());
    // send the file length
    out.writeLong(files[i].length());
    fileInput = new FileInputStream(files[i]);
    int count;
    while((count = fileInput.read(data, 0, BUFFER)) != -1) {
    out.write(data, 0, count);
    bytesSent += count;
    fileInput.close();
    out.flush();
    Does anybody know where's the problem? Thanx for any reply.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Send the length of each file ahead of each file, with DataOutputStream.writeLong().
    When reading, read that long, then stop reading bytes when you've read exactly that length.

Maybe you are looking for

  • Automatic creation of AuC

    Hi We are going live in next month. We are on SAP ECC6.0 and FICO MM SD are only implemented. PS is not implemented, In one of my BBP document, it is suggested that "The internal order will be changed to investment order and AuC will get created auto

  • Buy on iTunes, my card has no CCV (security code)

    I have a ebank account, they sent me the card... but the card has no CVV (security code) on the back, it's suppose to be 3 digits. So I made an PayPal account, but THEEEEEY won't send me a creditcard because I live outside the US. So I have an eAccou

  • Would someone be kind enough to look at my line st...

    Been connected 3 days now since signing up and ip profile is still at 2500kbps. Can I expect an improvement anytime soon? Thanks for looking. Master socket connected.. No other extensions. Exchange I can see from my living room window.. around 500m a

  • Sharing by Outlook after 3.4 Update No Longer Working...?

    Since the 3.4 update I can no longer email photos via Outlook as I used to be able to. Clicking the email button starts Outlook and then nothing esle. This happened before but using a method posted on here by a more experinced user had solved the pro

  • Wrong quotation symbol after Office 2010 SP1

    Hi, After we deployed Office 2010 SP1 to our internal test group we discovered that the quotation symbol is wrong. This has happend on every single computer we've installed it on. It only affects applications using Word, like editing e-mails in Outlo