File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes How to attach a TextFile as a File? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How to attach a TextFile as a File?" Watch "How to attach a TextFile as a File?" New topic
Author

How to attach a TextFile as a File?

Axel Foley
Greenhorn

Joined: May 23, 2002
Posts: 6
Hello,
I want to attach a Textfile to a Email and it works but the text is displayed in the Bodypart itself.
But I want it to be an attachment and not a part of the body!
How can I do that?
*Axel*
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Hi "corsa12". Welcome to JavaRanch!
Please change your name to comply with the naming policy to which you agreed when you registered here..

For your publicly displayed name,
use a first name, a space, and a last name.

You can change your name:
here

You can also find the naming policy:
here
Thank You!


Rob
SCJP 1.4
Ankur Goyal
Greenhorn

Joined: Feb 04, 2002
Posts: 13
Call the setDisposition(PART.ATTACHMENT) method on the body part


Let me know if I am wrong ! <img src="smile.gif" border="0">
Axel Foley
Greenhorn

Joined: May 23, 2002
Posts: 6
I do this, but the file is still coming in the body part and not as an attachment... :
...
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(pFile);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(pFile);
// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
mbp2.setDisposition(Part.ATTACHMENT);
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
...
whats wrong with that code?
*A*
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to attach a TextFile as a File?
 
Similar Threads
Save data into textfile
How to read lines from a text file
Reading a textfile stored in an jar archiv
Convert ListArray to string array
Servlet and I/O