This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
i used java mail api to program email sending. Now i have the problem that the attachment could not be treated as the independent attached file but displayed following the main text as the meanless characters, no matter what type of attachment i include, zip, au files. The main codes are: Session session = Session.getDefaultInstance(props, null); MimeMessagemsg = new MimeMessage(session); msg.addHeader("CONTENT-TYPE","multipart/mixed"); Transport tr = session.getTransport("smtp"); MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.addHeader("CONTENT-TYPE","text/plain"); mbp1.setText("hello world"); FileDataSource fds = new FileDataSource(somefilename); MimeBodyPart mbp2 = new MimeBodyPart(); mbp2.addHeader("CONTENT-TYPE","application/octet-stream"); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); Multipart mp = new MimeMultipart(); int index = 0; mp.addBodyPart(mbp1,index++); mp.addBodyPart(mbp2,index++); msg.setContent(mp); tr.sendMessage(msg,msg.getAllRecipients()); tr.close(); Thanks!
Joined: Dec 10, 2002
if i use "Transport.send(msg);" instead of "tr.sendMessage(msg,msg.getAllRecipients());", the attachment file shows ok, but the authentication process which must use a Transport instance can't be done properly. How can i resolve this conflict?