Results 1 to 3 of 3
- 07-22-2013, 12:37 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 39
- Rep Power
- 0
Email not being sent with attachment but working fine without attachment.
Hello every one,
I am trying to send email with attachment using java mail API.
My emails works perfectly and the message is sent without attachment, but when I add some attachment there exists an exception saying :
Java Code:javax.mail.MessagingException: IOException while sending message; nested exception is: java.io.IOException: No content
Java Code:JFileChooser jfc=new JFileChooser("."); int result= jfc.showOpenDialog(this); if(result==JFileChooser.APPROVE_OPTION) { filename=jfc.getSelectedFile().getPath(); }
Java Code:Multipart body=new MimeMultipart(); MimeBodyPart part1=new MimeBodyPart(); body.addBodyPart(part1); MimeBodyPart part2=new MimeBodyPart(); FileDataSource fds=new FileDataSource(filename); part2.setDataHandler(new DataHandler(fds)); part2.setFileName(fds.getName()); body.addBodyPart(part2); message.setContent(body);
Thanks and Regards,
heman
- 07-22-2013, 02:45 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 25
Re: Email not being sent with attachment but working fine without attachment.
Why do you have an empty body part for part1?
Please do not ask for code as refusal often offends.
** This space for rent **
- 07-22-2013, 05:09 PM #3
Member
- Join Date
- Aug 2012
- Posts
- 39
- Rep Power
- 0
Similar Threads
-
Soap attachment using axis 1.4
By RajeshPro in forum Web FrameworksReplies: 2Last Post: 01-10-2013, 12:59 PM -
SOAP application with File Attachment
By Ajitha in forum New To JavaReplies: 0Last Post: 10-08-2010, 04:56 AM -
Getting link attachment
By dynamolalit in forum Advanced JavaReplies: 0Last Post: 08-17-2009, 11:03 AM -
Problems with saaj and attachment
By seare in forum Advanced JavaReplies: 0Last Post: 07-20-2009, 01:29 PM -
Mail Attachment as Source
By vinoopraj in forum Advanced JavaReplies: 2Last Post: 06-15-2009, 06:21 AM
Bookmarks