Home Tutorialhelp Comment Read attachment form eml file

 
 

Comment

Ilamprai
Read attachment form eml file,
August 13, 2009 at 10:28 AM

i try to get details form .eml file, which contain attachment.it works if that attachment types are pdf/word..
but if that attachment type also .eml then i is not.Can you help to extract that attachment.
This is the code...
//
package tools;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;

import javax.activation.DataHandler;
import javax.mail.*;
import javax.mail.internet.*;

public class ReadMultipartMail {

public static void main(String args[]) throws Exception {
File emlFile = new
File("F:/test.eml");

InputStream source;

source = new FileInputStream(emlFile);

Properties props = System.getProperties();
props.put("mail.host", "smtp.dummydomain.com");
props.put("mail.transport.protocol", "smtp");

Session mailSession = Session.getDefaultInstance(props, null);
MimeMessage message = new MimeMessage(mailSession, source);
System.out.println("Subject : " + message.getSubject());
System.out.println("From : " + message.getFrom()[0]);

String from = InternetAddress.toString(message.getFrom());
if (from != null) {
System.out.println("From: " + from);
}

String replyTo = InternetAddress.toString(message.getReplyTo());
if (replyTo != null) {
System.out.println("Reply-to: " + replyTo);
}
String to = InternetAddress.toString(message
.getRecipients(Message.RecipientType.TO));
if (to != null) {
System.out.println("To: " + to);
}

String subject = message.getSubject();
if (subject != null) {
System.out.println("Subject: " + subject);
}
Date sent = message.getSentDate();
if (sent != null) {
System.out.println("Sent: " + sent);
}

System.out.println();
System.out.println("Message : ");

Multipart multipart = (Multipart) message.getContent();

for (int x = 0; x < multipart.getCount(); x++) {
BodyPart bodyPart = multipart.getBodyPart(x);

String disposition = bodyPart.getDisposition();

if (disposition != null
&& (disposition.equals(BodyPart.ATTACHMENT))) {
System.out.println("Mail have some attachment : ");

DataHandler handler = bodyPart.getDataHandler();
System.out.println("file name : " + handler.getName());
} else {
System.out.println(bodyPart.getContent());
}
}
System.out.println();
}

}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Java Beginners

How to read an eml file? - Java Beginners
How to read an eml file?  Hello dears, now i want to read en eml file stored in a folder. is it possible to use the same code for reading a txt file? or do i have to use javamail api? Thanks Spalax 

Java Mail

Handle EML(Electronic mail) file with Java Mail
Handle EML(Electronic mail) file with Java Mail       This Example shows you how to read any eml(Electronic mail) file using javamail api. eml is a simple email, all eml 

Java Mail

Read attachment message using Java Mail
Read attachment message using Java Mail       This Example shows you how to read a Attachment message using javamail api. Java Mail API provides classes to send multiple 

Struts Questions

send the mail with attachment - Struts
the mail without attachment file now. But i need to send the mail with attachment... the mail . Mail Problem is file path: how to get the file path from the browse("we need upload the file any location").Please help it is very urgent for me 

JSP Servlet Questions

To insert attachment file in database in JSP.
To insert attachment file in database in JSP.  I am doing project in JSP. How to insert attachment file in mysql database? Please suggest some... code: 1)page.jsp: <HTML> <HEAD><TITLE>Display file upload form 

Struts Questions

send the mail with attachment problem - Struts
InternetAddress(to)); message.setSubject("JavaMail Attachment...send the mail with attachment problem  Hi friends, i am using... to select the attached document from the jsp page(browser:");How to get the file 

JSP Servlet Questions

To insert attachment file in database in JSP.
To insert attachment file in database in JSP.  I am doing project in JSP. How to insert attachment file in mysql database? Please suggest some solution. Your inputs is valuable to me.   Hi Friend, Visit Here Thanks 

JavaMail Questions

problem in viewing the mail's content using javamail
); File file=new File("mails/"+user+"/"+Fetchmail.replacename(name)+".eml... the following code to view a mail in a javamail application problem i'm facing...; try{ files=file.getPath(); File 

Spring Framework Questions

upload attachment - Spring
upload attachment  java code in register form to upload an attachment storing in blog and clog   Hi Friend, Are you using JSP or Java Swings? Please clarify this. Thanks 

WebSevices Questions

AXIS ATTACHMENT MISSING - WebSevices
AXIS ATTACHMENT MISSING  Hi, i have a method which takes a filename as input. It reads the file and returns the content using MessageContext(Axis1.4... the attachment before returning. Kindly guide. Following is the server side code 

Java Technology Tutorials

Java read properties file
Java read properties file In this section, you will learn how to read properties file. Description of code: There are different tools to access different... can read any properties file. Output: Name: RoseIndia 

General

Read the File
Read the File       As we have read about  the BufferedInputStream class... the data is read in form of a byte through the read( ) method. The read 

J2ME

J2ME Read File
J2ME Read File       In this J2ME application, we are going to read the specified file. This example shows you how to read the data of the specified file. To implement this type 

JavaMail Questions

JavaMail API usage - JavaMail
JavaMail API usage  Hello sir, i wrote a program to send a message.... 3 > Pastes "mail.jar" file into "jdk1.5.0_02/jre/lib/ext/" directory. 4 > Pastes "activation.jar" file into "jdk1.5.0_02/jre/lib/ext/" directory 

JavaMail Questions

java - JavaMail
java  How to send out an email using simple java  How to send out an email with attachment using simple java  Hi Friend, Please visit the following links: http://www.roseindia.net/javamail/ Thanks 

JavaMail Questions

java code - JavaMail
that randomly generates rupee and dollar objects and write them into a file using object serialization.write another program to read that file,convert to rupee...); System.out.println("Reading from file:"); for(int i=1;i<=10;i++){ curr 

JavaMail Questions

mvc coding - JavaMail
mvc coding  Hi friends, I am facing this problem, I created .vm files and class files in eclipse but velocity.log file show this problem...; Hi friend, Read for more information about mvc http 

JavaMail Questions

JavaMail flagging problems - JavaMail
JavaMail flagging problems  Hi everyone, I am working on receiving... and read only those mails which have this as the subject line. My problem... the mails as 'read' and read only the unread mails the next time i run the program 

Java Beginners

read image
read image  java code to read an image in the form of an array.   import java.io.*; import javax.imageio.*; import java.awt.image.*; class... Exception { File input = new File("C:/rose.jpg"); BufferedImage 

JavaMail Questions

JavaMail API - JavaMail
JavaMail API  Hi My Name is Satish I have a Problem with Java Mail API when I am doing Maling programme I can able to do single mail and single CC...) { } } }   Hi friend, Read for more information about Mail API: http 

Java Beginners

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 

JSP Servlet Questions

sending mail with attachment in jsp - JSP-Servlet
sending mail with attachment in jsp  Hi, Can any one pls tell me how to send email with attachment in jsp. I know how to send mail without attachment but with attachment its not working for me. If u hve any idea please 

JavaMail Questions

Mailing - JavaMail
Mailing  Dear Friends, How can i send mails to yahoo,gmail,other mail servers using javamail using a jsp file. Please help me 

Java Beginners

file read
file read  hi i am reaing from a file which has punjabi words. can some one help with me some code 

Java Mail

Read Multipart mail using Java Mail
Read Multipart mail using Java Mail       This Example shows you how to read a multipart message using javamail api. When we read a multipart mail firstly create 

Core Java

How to read properties file in java
How to read properties file in java Description of Example:- In this example... file, stored data as a key value pair in the form of string. It has two method read properties file;- ResourceBundle. Properties Class.   

Java Beginners

How to read the contents in a file which is of input type file
How to read the contents in a file which is of input type file  I have a jsp page wherein i have to passs the file as input and read the contentsn of a file in servlet. upload.jsp <FORM METHOD=POST ENCTYPE="multipart/form 

JavaMail Questions

extract content from javamail - JavaMail
extract content from javamail  Hi, I currently try the example(Read Multipart mail using Java Mail) on Javamail from the site to receive the e-mail. Then If I going to extract text the message content. What can I do 

JavaMail Questions

file uploading - JavaMail
file uploading  Hi thi is swathi.Thank s for giving the answers to previous questions.I am getting the problem with below code FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new 

Java Mail

Sending Email with Attachment
Sending Email with Attachment       This Example shows you how to send a Attachment in the message using... attachment in the content and Finally, it sends the Message by invoking 

JavaMail Questions

PROGRAMMING - JavaMail
PROGRAMMING  could show me how to write a psuedocode to read a sequence of numbers terminated by 999 the psuedocode should count and print the number of negative values and zero for this assessment PLZZZ 

JavaMail Questions

java - JavaMail
java  sir I want some java file codings pls send it.........  Hi Friend, Please visit the following code: http://www.roseindia.net/java/example/java/io/ Thanks 

Java Beginners

Read file in java
Read file in java  Hi, How to Read file in java? Thanks   Hi, Read complete tutorial with example at Read file in java. Thanks 

Java Beginners

java read file
java read file  Hello i need some help... i want to read an MS Excel file in java so how to read that file 

Java Beginners

Read and write file
Read and write file  HI, How to read and write file from Java program? Thanks   Hi, See the following tutorials: Java Write To File Read File Thanks 

PHP Questions

Read external file in PHP
Read external file in PHP  How to read external files in PHP in particular time duration and save that file with the latest date. How is it possible? Please explain with an example. Thanks 

Java Beginners

Read from file java
Read from file java  How to Read from file java? What is the best method for a text file having a size of 10GB. Since i have to process the file one line at a time so tell me the very best method. Thank you 

Java Beginners

Java read binary file
Java read binary file  I want Java read binary file example code that is easy to read and learn. Thanks   Hi, Please see the code at Reading binary file into byte array in Java. Thanks   Hi, There is many 

JavaMail Questions

down load jar file - JavaMail
 

Java Beginners

Read Video File
Read Video File  how to read a video file, after that i want to encrypt and decrypt it. please help me and if u can send me some hint or source code on swarit.it@gmail.com Thanks & Regards Swarit Agarwal 

Java Interview Questions

Read the file Contents
Read the file Contents  Ravi Raj,Vijay45Shankar,234 Guna,345,Meet me,654,Cow Read file contents and Print the no.of words and Numbers./p> Thanks, Dinesh Ram   The given code read the file content and print 

JavaMail Questions

regarding email - JavaMail
, port: 25" is that you've incorrectly configured your properties and JavaMail... or not? If not, then something has happened to the Properties that JavaMail... that object. For read more information on Java Mail visit to : http 

Java Beginners

Read text File
Read text File  Hi,How can I get line and keep in a String in Java 

JavaMail Questions

Role based login ..Need the concepts.. - JavaMail
points remember "login.jsp" 1)Code have two file "login.jsp" and "welcome.jsp... have any more problem then give in details. Read for more information 

JavaMail Questions

java mail api - JavaMail
in the classpath. 3.Start the mail server. For read more information,Examples...-in-jsp.shtml http://www.roseindia.net/javamail/ Thanks 

Java Beginners

read restricted pdf file
read restricted pdf file  i have restricted file. package Encryption; import java.io.*; import java.util.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; public class EncryptionWithCertificate 

Java Beginners

read restricted pdf file
read restricted pdf file  i have restricted file. package Encryption; import java.io.*; import java.util.*; import com.lowagie.text.*; import com.lowagie.text.pdf.*; public class EncryptionWithCertificate { public 

JavaMail Questions

java complilation error - JavaMail
java complilation error  Hi I was trying to send the mails using the below code,This coding is giving errors that java.mail.* does not exists,i am.../Downloadantjavamailjar.htm and add this jar file into the lib folder in ur netbeans 

JavaScript Questions

read doc and docx file in javascript
read doc and docx file in javascript  How i read doc and docx file in javascript 

JavaScript Questions

read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript 

Mobile Applications Questions

J2ME Read Multiple File - MobileApplications
J2ME Read Multiple File  Hello I have read a topic "J2ME Read File", but that example is specify for a single file, but what if i want read more file one after the other just like Books. And an example will i appreciate thanks 

JavaMail Questions

JAVA MAIL - JavaMail
desposition is Part.ATTACHMENT. If it is then you can get these attachment files 

Mobile Applications Questions

Read file zip in J2ME - MobileApplications
Read file zip in J2ME  I would like to read file.zip in J2ME,I don't know how to extract it. Please help me 

JUNIT Questions

Read Property file From Jmeter
Read Property file From Jmeter  Hi, I am running web driver script from Jmeter, but while reading property file I am getting "File Not Find Exception". Please tell me how to read ".properties" file from Jmeter 

Java-Tutorials

Read the Key-Value of Property File in Java
Read the Key-Value of Property File in Java       In this section, you will learn how to read the key-value of properties files in Java. The properties file provides 

Java Beginners

read paragraph
read paragraph  how to read paragraph from one file to another file 

Java Technology Tutorials

Java read file in memory
Java read file in memory In this section, you will learn how to read a file... and then read the file... for the  file, and then call map( ) to produce a MappedByteBuffer, which 

General

Java Read username, password and port from properties file
Java Read username, password and port from properties file In this section, you will come to know how to read username, password and port no from.... In the properties file, data has been stored as a key value pair in the form of string. load 

Java-Tutorials

How to Read a File in Java
How to Read a File in Java? In this section we are going to know, How to read a file in Java. We have to follow three step to read a File. First get... to read the Content of file . Read A File: Reading a file is nothing 

Java Code Examples

Java Read CSV file
Java Read CSV file In this tutorial, you will learn how to read csv file. CSV (Comma Separated Value) is a common type of data file which can be exported... opened a file data.csv  and created a BufferedReader object to read 

Java Beginners

Java read lines from file
to read the whole file in one go. So, in my case reading file line by line is only...Java read lines from file  Any code example related to Java read lines from file? In my project there is requirement of reading the file line by line 

Programming Tutorials

Read PDF file
Read PDF file Java provides itext api to perform read and write operations with pdf file. Here we are going to read a pdf file. For this, we have used PDFReader class. The data is first converted into bytes and then with the use 

Java Beginners

Read bufferedreader
Read bufferedreader  Tell me the example of Read file using bufferedreader. Thanks   Read the tutorial Reading file using BufferedReader class. Thanks 

XML Questions

how to read this xml file - XML
how to read this xml file  i want to read this xml file using java... read i have tried lot more , but i am not able to read this xml file... name=client menu=client action=read user employee add 

Java Technology Tutorials

Read file into String
Read file into String In this section, you will learn how to read a file... data from the file using it's read() method. This data is then stored... we have used FileReader and BufferedReader class to read the file into memory 

Java Beginners

Read Lines from text file
read from the text file and displays the output as desired. Unable to read the rest...Read Lines from text file  Here's a brief desc of what my Java code does .. I'm using BufferedReader to read lines from a text files and split each 

HTML Questions

How to save form data to a csv file using jquery or ajax
How to save form data to a csv file using jquery or ajax  Please let... this. i am able to read the csv file using this code if (window.XMLHttpRequest...=data.responseText; Now the problem is ,i should write form data to a csv file using ajax 

PHP Tutorial

Read a zip file.
zip_entry_read() In this example the function zip_entry_read() will help in reading a zip file. First select a file to be opened. Name that file into zip file and direct the zipread command to read it through while loop. The zip_entry 

JavaMail Questions

PDF reader in android - JavaMail
PDF reader in android  Hi, iam trying to open and perform basic operations on PDF file in android. But i unable to get it. IS there any possibilities to solve that problem? Waiting for reply 

Java Beginners

Java file read write operation
Java file read write operation  how to read and write the data from text file.Suppose i have text file with 4 fields name ,roll no ,marks1,marks2 with more than 20 records......i need to store these value in object and pass 

JavaMail Questions

call from java - JavaMail
----------------------------------------------- Read for more information. http 

JavaMail Questions

Java Mail API - JavaMail
Java Mail API  Hi! I wish u advanced happy new year to all of ur team members.... My question is.. I want to read attachments in my gmail account using java mail api... i got code from our roseindia.net i.e. 

JavaMail Questions

sending automatic email - JavaMail
. For this you need some third party tool. Create an exe file of your applcation. put 

JavaMail Questions

Sending mail - JavaMail
()); message.setText(content); File f = new File("Message.properties"...;+messageIdKey); message.setHeader(messageIdKey,"1000"); /* File f = new File("Message.properties"); Properties pro = new Properties 

General

Reading a File into a Byte Array
a file in the form of a byte array. We can do it very easily. Firstly we... to read, in the constructor of File class. We will use DataInputStream to read... .style1 { color: #FFFFFF; } Reading a File into a Byte Array 

Programming Tutorials

Java read latest file
Java read latest file Java provides IO package to perform file operations. Here we are going to read the last modified file. For this, we have used..., read that particular file. Here is the code: import java.io.*; import 

Java Magazine Questions

xl read
: Insert excel file data into database Read Excel File...xl read  hi, i have read excel sheet data using poi api and printed on console, now i have to store the same data which is printed on the console 

Java Beginners

Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory 

JavaMail Questions

javamail
 

C Tutorials

C file read example
C file read example       This section demonstrates you to read a line from the file. You can see in the given example, we prompt the user to enter the name of the file to read 

Java Beginners

read xml
read xml   hi all, i want to ask about how to read an xml in java ME.. here is the xml file <data> <value> <struct> <member> <name> User_Name 

Java-Tutorials

Java read file
There are many ways to read a file in Java. DataInputStream class is used to read text File line by line. BufferedReader is also used to read a file in Java... line. Example of Java Read File: package FileHandling; import 

PHP Questions

php send mail with attachment
php send mail with attachment  Syntax of sending email with attachment in PHP 

Mobile Applications Questions

objective c read file line by line
objective c read file line by line  Please explain how to read files in Objective C line by line 

EJB Questions

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 

PHP Questions

How to Open a File in HTML Form
How to Open a File in HTML Form  Hi, My question in that how could i open a file in HTML Form. Could any one suggest me the examples or online help... it. Otherwise take this examples and syntax that will show how to Open a file in HTML 

WebSevices Questions

Webservices with attachment on websphere - WebSevices
Webservices with attachment on websphere  Need some help urgently!!! I need to provide an interface with webservices to access one of our services...). 2. Have some one some example ready for attachment with webservices 

Java Beginners

Java read entire file into byte array
Java read entire file into byte array  Where is the example of Java read entire file into byte array on your website? Thanks   Hi, Its simple you can use insputStream.read(bytes); method of InputStream class. Read 

Java Beginners

Java read file contents into byte array
Java read file contents into byte array  Hello share the code of java read file contents into byte array with me. It's urgent. Thanks   Hi, This is simple process if you use the InputStream class. Read example 

Java Beginners

how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java 

Java-Tutorials

How To Read File In Java
How To Read File In Java In this section we will discuss about about how data of a file can be read in Java. A file can contain data as bytes, characters, binary data etc. To read a file in Java we can use following of the classes 

Java Beginners

read excel file from Java - Java Beginners
read excel file from Java  How we read excel file data with the help of java?  Hi friend, For read more information on Java POI visit to : http://www.roseindia.net/java/poi/ Thanks 

JSP Servlet Questions

Read Text file from Javascript - JSP-Servlet
Read Text file from Javascript  plz send the code How to Retrieve the data from .txt file thru Javascript? And how to find the perticular words in that file 

Java-Tutorials

How To Read File In Java with BufferedReader
How To Read File In Java with BufferedReader class - example code This tutorial shows you how you can read file using BufferedReader class in your program... java.io.*; /** * How To Read File In Java with BufferedReader class 

Java Beginners

To read & write a excel file using the core java
To read & write a excel file using the core java  Hai, I'm new to JavaProgram.But now i need java program to read & write a excel file so, can anyone help me to learn the above mentioned topic(link for the portion 

Java Code Examples

Java read file line by line
Java read file line by line In this section, you will learn how to read a file... are going to read a file line by line. For reading text from a file it's better... class is used to read text from a file line by line using it's readLine method 

Struts Questions

how to read the .proprties file from struts - Struts
how to read the .proprties file from struts   errpr is :file not found exception:applicationresource.proprties file {system canot find file path"; How to set the file path.  Hi Friend, It seems that you haven't 

Java Beginners

How to read the .doc/ .docx file in Java Program
How to read the .doc/ .docx file in Java Program  Hi, I am beginner in Java programming language. Can anybody explain How to read .doc file in Java... to read the word document file. For doing this we will make class HWPFDocument which 

Java Beginners

read from file and store using hash map
read from file and store using hash map  I was stuck with a java project where I have to read a file with two different concepts and store them differently in hashmap. My data file would be something like Adults: Name, xyz 

PHP Tutorial

PHP Form, PHP guest form
{//if there is a counter file, //let's read it's value to the array $n, add 1 and close...!"); }else{//if there is a message file //read messages from...PHP email form HTML form It's not a good idea to leave your private e 

Advertisements Advertisements
 

 

 

DMCA.com