• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to attach a TextFile as a File?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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*
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Call the setDisposition(PART.ATTACHMENT) method on the body part
 
Axel Foley
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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*
reply
    Bookmark Topic Watch Topic
  • New Topic