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



Home Answers Viewqa EJB file attach

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  how can add the information to the graphic file
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 to find all files in our local computer using java
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  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
Convesion of txt file to doc file.??????
Convesion of txt file to doc file.??????  how to convert text file to doc file using java
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
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
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
WAR file
WAR file  What is a WAR file
File Transfer
File Transfer  How to create a file in server side using java swing
File Upload
File Upload  when i execute the image upload to mysql database it shows an exception that file path cannot be found
deleting file
deleting file   how to delete a file from a folder and its corresponding path in database using a servlet
JSP File
JSP File  Hi, What is JSP File? How to create JSP file? Thanks   Hi, JSP file is simple text file with .jsp extenstion. You can run JSP file on tomcat server. Read more at JSP tutorials section. Thanks
JAR FILE
JAR FILE  WHAT IS JAR FILE,EXPLAIN IN DETAIL?   A JAR file... and applications. The Java Archive (JAR) file format enables to bundle multiple files into a single archive file. For more information, visit the following
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
on file system
on file system  how to maintains record in a file using java and how to create objects to each record.   Hi, Please read Java Write file tutorial. Regards Deepak
File Upload
File Upload  Hi I need script / string in PHP where I uploaded the file in html frontend and it should sent the uploaded file as attachment to my email address
Java Execute Jar file
the classes into one JAR file, we make it portable that can be run anywhere and on any operating system or platform. To execute a JAR file, one must have Java... step is to make the JAR file executable. All class files of the application
jar file
jar file  steps to create jar file with example
jar file
jar file  jar file where it s used
jar file
jar file  how to create a jar file in java
File handlig
File handlig  File hyandling   Hi Please the click on the following link Java file Handling And read the Articles given in it   Hi Please the click on the following link Java file Handling And read
FILE CONCEPT
FILE CONCEPT  Prompt the user to enter the name of a text file to search for. If the name does not end in a .txt extension, display an error message. Search for this file in the current directory. If the file does not exist print
class file
class file  How to create class file in jsf easily
File transfer
File transfer  Hi there... I would like to know is it possible to transfer files from one directory to another with out file io operations
file download
file download  I uploaded a file and saved the path in database. Now i want to download it can u plz provide code
file searching
file searching  i need a prog for searching inside a text file after evry 1 min to find does it hav any new entry
file read
file read  hi i am reaing from a file which has punjabi words. can some one help with me some code
file upload
file upload  how to recieve the uploaded file on the next jsp page for modification if its uploaded to the previous page using a from
read a file
read a file  read a file byte by byte   import java.io.File... static void main(String[] args) { File file = new File("D://Try.txt"); try { FileInputStream fin = new FileInputStream(file); byte
 

 

 

DMCA.com