Results 1 to 14 of 14
- 01-03-2008, 06:04 PM #1
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
copying file from a email/word to a Java application
Hi,
I have a requirement to copy a file in a email or a word document to a java application. Using system clipboard i can copy a file in a hard drive location in a PC to the Java application, but i am not able to copy a file from an email to java application.
Please provide some inputs if you have any idea regarding this.
Regards,
cmbl
- 01-04-2008, 04:56 AM #2
do you want to attach file to an email using javamail api ? or do you want to copy file attached to an email from your outlook inbox ?
- 01-04-2008, 11:31 PM #3
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
I want to copy a file attached to an email in the outlook inbox to the Java application.
- 01-04-2008, 11:49 PM #4
Copying ?? i am still confused .. do you want to read file attached in email ?
dont worry newbie, we got you covered.
- 01-07-2008, 04:55 PM #5
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
yes, I need to read the file attahced in email. How do read it?
- 01-07-2008, 05:41 PM #6
Member
- Join Date
- Jan 2008
- Posts
- 20
- Rep Power
- 0
ultipart mp = (Multipart)(message[0].getContent());
// Displays Inbox
for (int i=0; i < message.length; i++) {
System.out.println(i + ": " + message[i].getFrom()[0]
+ "\t" + message[i].getSubject());}
for (int i=0, n=mp.getCount(); i<n; i++) {
Part part = mp.getBodyPart(i);
String disposition = part.getDisposition();
if ((disposition != null) &&
(disposition.equals(Part.ATTACHMENT) ||
(disposition.equals(Part.INLINE)))) {
// Save Attachment
File attachFile = new File(part.getFileName());
for (int j=0; file.exists(); j++) {
attachFile = new File(part.getFileName()+j);}
ObjectOutputStream out = new ObjectOutputStream(
new FileOutputStream(attachFile));
out.writeObject(part.getInputStream());
out.close();
}
}System.out.println("Logged in as ROOT");
- 01-07-2008, 05:58 PM #7
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
thanks.
The above code gets all the emails in the mail box. But what i need is, i need to read the attachment of the mail which i have opened into the java application.
For this i was taking a different approach of using a Clipboard, because when we do CTRL+C on a file attachment in a email, the attachment is copied to the clipboard as bytes. I need to know how to read the contents in the System clipboard which are in bytes. We need to define a DataFlavor to read bytes from System Clipboard.
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.getData(DataFlavor.StringFlavor);
A string flavor means any data as strings are retrieved. What i need to get is the data which is in bytes.
Hope u r clear with the
- 01-07-2008, 06:30 PM #8
Member
- Join Date
- Jan 2008
- Posts
- 20
- Rep Power
- 0
Part and disposition does that ..
Did you try that codeSystem.out.println("Logged in as ROOT");
- 01-07-2008, 06:33 PM #9
Member
- Join Date
- Jan 2008
- Posts
- 20
- Rep Power
- 0
One more thing, I was not clear on what you mean by " i need to read the attachment of the mail which i have opened into the java application.
" Please clarify.System.out.println("Logged in as ROOT");
- 01-07-2008, 06:45 PM #10
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
What i meant was, when a mail is opened and it has an attachment. what i do is CTRL+C the attachment. this gets copied as bytes to the clipboard. I need to read the file which is in bytes in Clipboard. Hope it's clear now...
- 01-07-2008, 06:50 PM #11
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
In the above code to get the Messages, do i need to provide the authentication info to connect to the mail server. or is it possible to get the messages from the mail server and user info available on the pc. I would like to know is it possible to set up connection to the mail box available on a user pc.
- 01-07-2008, 08:42 PM #12
Member
- Join Date
- Jan 2008
- Posts
- 20
- Rep Power
- 0
Yes its possible..
System.out.println("Logged in as ROOT");
- 01-07-2008, 09:04 PM #13
Member
- Join Date
- Jan 2008
- Posts
- 7
- Rep Power
- 0
Please let me know how it can be done or the link where i can find it.
- 01-09-2008, 06:51 AM #14
Member
- Join Date
- Jan 2008
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
Live Email Validation In Java
By shameel in forum Web FrameworksReplies: 9Last Post: 01-05-2010, 05:42 AM -
Java Email Server 1.6
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-21-2007, 08:00 PM -
Access Email usind a java mail client Access Email usind a java mail client
By consult4u in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 07-31-2007, 08:29 AM -
How to update Existing Word Doc Using java
By umashankar in forum Advanced JavaReplies: 1Last Post: 07-27-2007, 01:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks