Topic: JavaMail中附件上传的问题

  Print this page

1.JavaMail中附件上传的问题 Copy to clipboard
Posted by: adelejxsx
Posted on: 2003-04-10 17:17

附件上传时用的是Servlet,在本机可以上传 ,但用别的机器访问服务器上传附件时却提示找不到系统路径,不知道为什么?

2.Re:JavaMail中附件上传的问题 [Re: adelejxsx] Copy to clipboard
Posted by: lbluekey
Posted on: 2003-04-10 19:04

能不能将错误打印出来看看?我这样做的没有问题呀!

3.Re:JavaMail中附件上传的问题 [Re: adelejxsx] Copy to clipboard
Posted by: adelejxsx
Posted on: 2003-04-11 10:46

我的错误信息是JAVAMAIL报的,等 一下我贴出来,
你能否把代码给我一看,感激不尽。

4.Re:JavaMail中附件上传的问题 [Re: adelejxsx] Copy to clipboard
Posted by: adelejxsx
Posted on: 2003-04-11 11:12

javax.mail.SendFailedException: Sending failed; nested exception is: class javax.mail.MessagingException: IOException while sending message; nested exception is: java.io.FileNotFoundException: C:\axis.cmd (系统找不到指定的文件。)

5.Re:JavaMail中附件上传的问题 [Re: adelejxsx] Copy to clipboard
Posted by: lbluekey
Posted on: 2003-04-16 22:16


String mailto = req.getParameter("sendto");
String cc = req.getParameter("cc");
String bcc = req.getParameter("bcc");
String subject = req.getParameter("subject");
String content = req.getParameter("content");
Properties props = System.getProperties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", "smtp.vip.sina.com");
if(mailto == null)
return new MsgInfo(false,"没有输入收件人地址!");
SmtpAuthenticator sa=new SmtpAuthenticator();
Session sess = Session.getInstance(props,sa);
//sess.setDebug(true);
Message msg = new MimeMessage(sess);
msg.setFrom(new InternetAddress(fromMail));
// String tos[] = UtilBean.divideString(mailto,"';");
// for(int i=0;i<tos.length ;i++)
//System.out.println(mailto);
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(mailto, false));
if(cc!=null)
msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(cc, false));
if(bcc!=null)
msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(bcc, false));
msg.setSubject(subject);
msg.setSentDate(new Date());
// msg.setText(content);
// msg.setContent();
// create the Multipart and its parts to it
Multipart mp = new MimeMultipart();
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(content);
mp.addBodyPart(mbp1);
for (int i=0;i<myUpload.getFiles().getCount();i++)
{
String fileName = myUpload.getFiles().getFileLight Bulb.getFileName();
if(fileName.length()==0)
continue;
// System.out.println(fileName+"AAAAAAA");
byte[] fileData = myUpload.getFiles().getFileLight Bulb.getData();
MimeBodyPart mbp = new MimeBodyPart();
mbp.setDataHandler(new javax.activation.DataHandler(new MailDataSource(fileData,"application/x-msdownload"))); // InternetHeaders(),fileData);
mbp.setFileName(new String(fileName.getBytes("GBK"),"ISO-8859-1"));
mp.addBodyPart(mbp);
}
// add the Multipart to the message
  msg.setContent(mp);
Transport.send(msg);


我是使用JspSmartUpload来实现附件上载的哦

6.Re:JavaMail中附件上传的问题 [Re: adelejxsx] Copy to clipboard
Posted by: adelejxsx
Posted on: 2003-04-17 09:57

byte[] fileData = myUpload.getFiles().getFileLight Bulb.getData();
这行代码中的方法getData()好像没有。我用的也是jspsmartUpload

MimeBodyPart mbp = new MimeBodyPart();

mbp.setDataHandler(new javax.activation.DataHandler(new MailDataSource(fileData,"application/x-msdownload")));
这行代码中的new MailDataSource(fileData,"application/x-msdownload")这个MailDataSource类在哪里哪,我怎么找不到。

--------------------------------------------------------------------------------
• IBM与BEA的比较


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923