• 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 send email with no attachment?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
MimeBodyPart textPart = new MimeBodyPart();
textPart.setText(text);

I've written a email servlet using Java Mail that allows file attachment.
The problem that I'm having is that every time I send an email without a attach file. The email does not sends out.
Please advise! Alvin
Here's my code looks like:
======================================
Multipart mp = new MimeMultipart();

MimeBodyPart attachFilePart = new MimeBodyPart();

FileDataSource fds = new FileDataSource(attachment);
attachFilePart.setDataHandler(new DataHandler(fds));
attachFilePart.setFileName(fds.getName());

mp.addBodyPart(textPart);
mp.addBodyPart(attachFilePart);
message.setContent(mp);
 
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic