Results 1 to 2 of 2
Thread: exeption haldling
- 04-23-2010, 06:40 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 19
- Rep Power
- 0
exeption haldling
below is my snippet where i am trying to attach a file n send through java...if i attach a file den d mail will go,,if i wont attach a file den exception occurs even after putting the code wr i just want to print my body part.kindly plz help out
try
{
if(src!=null) // code wr i attach a file
{
MimeBodyPart p1 = new MimeBodyPart();
text=jTextArea6.getText();
p1.setText(text);
MimeBodyPart p2 = new MimeBodyPart();
p2.attachFile(src);
p2.setHeader("Content-Type","multipart/mixed");
src=atttxt.getText();
//String data = "any ASCII data";
//DataSource fds = new ByteArrayDataSource(data, "application/x-any");
FileDataSource fds = new FileDataSource(src);
p2.setDataHandler(new DataHandler(fds));
p2.attachFile(src);
p2.setFileName(fds.getName());
//p2.setDisposition(MimeBodyPart.ATTACHMENT);
// p2.addHeader("Content-type", "text/plain; charset=us-ascii");
p2.setHeader( "content-type","Content-Transfer-Encoding: BASE64") ;
Multipart mp = new MimeMultipart();
mp.addBodyPart(p1);
mp.addBodyPart(p2);
msg.setContent(mp);
msg.setSubject(subject);
msg.setDisposition(src);
charset="iso-8859-1";
msg.setHeader("content-type","text/plain");
msg.setFileName(src);
msg.setText(text);
}
}
catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}
}
finally
{
msg.setSubject(subject); // here i just want ro send a body part
msg.setText(text);
}
pls check out whether my code is correctSNIFFER
- 04-23-2010, 09:38 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
null pointer exeption
By mj23brm in forum New To JavaReplies: 4Last Post: 02-10-2009, 11:50 PM


LinkBack URL
About LinkBacks

Bookmarks