Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa EJB file attach
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sonali.vinay.barbhaya
file attach
6 Answer(s)      3 years and 11 months ago
Posted in : EJB


how pick up the file from database and attach it to the mail in java


Advertisement
View Answers

October 21, 2010 at 2:38 PM


Hi,

Here is the code to read image (file) from database. Read tutorial Read image from database.

The relevant part of code is:

  rs1 = st1.executeQuery("select image from pictures where id='5'");
  if(rs1.next()){
    int len = imgLen.length();
    byte [] rb = new byte[len];
    InputStream readImg = rs1.getBinaryStream(1);
    int index=readImg.read(rb, 0, len);  
    System.out.println("index"+index);
    st1.close();
    response.reset();
    response.setContentType("image/jpg");
    response.getOutputStream()**.write(rb,0,len);**
    response.getOutputStream().flush();        
  }

After reading the image you can save into file or attach as attachment in your email.

Thanks



October 22, 2010 at 10:23 AM


Hi,

Example code of Java email with attachment.

Thanks



October 22, 2010 at 1:15 PM


hie thank you so much could you help me out for a code with the pdf or a text file from the data base where the contents of file are stored int binary format



October 22, 2010 at 1:17 PM


i am making use of POJO



October 22, 2010 at 3:27 PM


i get the following exception from my code
javax.mail.MessagingException: IOException while sending message; nested exception is: java.io.IOException: No content



October 25, 2010 at 10:33 AM


hey my code works fine thank you



Related Tutorials/Questions & Answers:
file attach
file attach  how pick up the file from database and attach it to the mail in java   Hi, Here is the code to read image (file) from... the image you can save into file or attach as attachment in your email. Thanks
attach file in my web page
attach file in my web page  hide button in input typ=file button in jsp
Advertisements
What type of headers have to be added in the mail function to attach a file?
What type of headers have to be added in the mail function to attach a file?  What type of headers have to be added in the mail function to attach a file
How to attach file to HP Quality Center [QC] using java
How to attach file to HP Quality Center [QC] using java  Hello All, Do any one know how to upload attachments to QC Test Case Run Instance using... Run Instance<BR> So i wish to attach files with the <B>Test Run
can u plz help out how to attach file directly & send to a particular mail id
can u plz help out how to attach file directly & send to a particular mail id  i am building a project online LEAVE MANAGEMENT SYSTEM to our coll mini project so if a faculty write all details abt leave & shd send to HOD
Attach a Image fiel to Webservice - WebSevices
... to this String I need to attach an Image file to this. (That is when client...   We can attach a file or an object or a collection to the webservice. Use.... they can get the required details from that file.  We can attach a file
attach a calendar in java
attach a calendar in java  how i attach a calendar near the box of date of birth in application form of java   Hello Friend, Try the following code: import java.awt.*; import java.awt.event.*; import javax.swing.
How to create and Attach MS Access Reports and Crystal Reorts in Java. - Java Beginners
How to create and Attach MS Access Reports and Crystal Reorts in Java.  How to create and Attach MS Access Reports and Crystal Reorts in Java WITH MS Access 2007 Database, plz Help Me Sir
File
File  How to create .Exe file in jana
file
file  how can copy the information in the file to the string?   Store file data into String
file
file  Could anyone please help me to write a code that does the following: Opens a file named MyName.txt, reads the first line from the file and displays it, and then closes the file. Thank you so much
file
file  Hi,what can delet some of the information of the file
file
file  Hi,how can delet some of the information of the file
file
file  how can add the information to the graphic file
FILE
FILE  There is a file named Name.txt that contains information related to appliances.I want to read the contents of this file and I used the code... args[]) { try { File file=new File("Name.txt"); FileReader f=new FileReader(file
File
File   How to find all files in our local computer using java
file
file  hi i want read special line of file. what am i doing ? I write... read data from file. please help me! void maketree(BtNode root,int i) throws... at the following link: Read specific line from file
Source file upload by attaching multiple files
Source file upload by attaching multiple files  Thanks for the answer. The answer posted in this link I want to have a single text box and when i... a provision to attach multiple images/files like in gmail. Is there any solution
File path for jar file
File path for jar file  Hi Experts, I have created one eclipse... jar file of that application, unfortunately it is giving the error that resource not found for the template file. Also I had tried to get that path from user
EAR file
EAR file   What is the EAR file
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Convesion of txt file to doc file.??????
Convesion of txt file to doc file.??????  how to convert text file to doc file using java
File manipulations
File manipulations  how to read input to a file from console
File manipulations
File manipulations  how to count number of words in a file
File manipulations
File manipulations  how to read the contents from one file and move the contents to another file
EAR file
EAR file   What is the EAR file ?   An EAR file is a standard JAR file with an .ear extension, named from Enterprise ARchive file. A J2EE application with all of its modules is delivered in EAR file
File Operations
File Operations  Please i would like to know if it is possible to read from a file and write to the same file at the same time
WAR file
WAR file  What is a WAR file
upload only pdf file - Struts
upload only pdf file  in web application,i want to attach only pdf file but if i change the extension of EXE or TXT files with PDF Extension its also upload ,but i want to upload only pdf file not only the extesion but also
deleting file
deleting file   how to delete a file from a folder and its corresponding path in database using a servlet
File Upload
File Upload  when i execute the image upload to mysql database it shows an exception that file path cannot be found
Advertisements
 

 

 

DMCA.com