my dog learned polymorphism*
The moose likes Servlets and the fly likes How to send email with no attachment? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to send email with no attachment?" Watch "How to send email with no attachment?" New topic

How to send email with no attachment?

Alvin de Jesus

Joined: May 05, 2001
Posts: 3
MimeBodyPart textPart = new MimeBodyPart();

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));

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How to send email with no attachment?
Similar Threads
problem with java mail attachment
How to attach a TextFile as a File?
send attachment Using JSP with JavaMail
setting content in email with attachment JavaMail
Sending MAIL by Java