In my app lib, there are geronimo-spec-j2ee-1.4-rc4.jar, which has mail 
api.When I send mail with
MimeBodyPart and MimeBodyPart, the error message is:

Exception in thread "main" java.lang.UnsupportedOperationException: Method not 
yet implemented
        at javax.mail.internet.MimeBodyPart.setFileName(MimeBodyPart.java:167)
        at test.HtmlJavaMail.sendMail(Unknown Source)
        at test.HtmlJavaMail.main(Unknown Source)


When I remove geronimo-spec-j2ee-1.4-rc4.jar and left the mail.jar, there is no 
problem.

So I think there is any conflict between geronimo-spec-j2ee-1.4-rc4.jar and 
mail.jar. How can I
resolve this problem ? 



----------------------------------------------------------
sendMethod() {  
        Properties props = new Properties();

        props.put("mail.smtp.host", MailSettings.smtpHost);
        props.put("mail.debug","true");
        props.put("mail.smtp.auth","true");     
        Session session = Session.getDefaultInstance(props, new 
ForcedAuthenticator());

        Message message = new MimeMessage(session);

        message.setFrom(new InternetAddress(MailSettings.fromAddress,
                        MailSettings.fromName));

        message.setRecipient(Message.RecipientType.TO, new InternetAddress(
                        MailSettings.toAddress));

        message.setSubject(MailSettings.messageSubject);

        MimeMultipart multipart=new MimeMultipart();
        
        BodyPart msgBodyPart=new MimeBodyPart();
        String contentType= msgBodyPart.getContentType();
        
        String msg = "<H1>Hi! From HtmlJavaMail Chinese=中文</H1><img 
src=\"cid:logo\">";

        msgBodyPart.setContent(msg,"text/html;charset=gbk");
        
        MimeBodyPart mBodyContent=new MimeBodyPart();
        FileDataSource theDs = new FileDataSource("D:\\abc.txt");  
        mBodyContent.setDataHandler(new DataHandler(theDs));
        String attachedFileName = "abc.txt";
        attachedFileName = MimeUtility.encodeText(attachedFileName,"gbk","B");
        mBodyContent.setFileName(attachedFileName);     
        multipart.addBodyPart(mBodyContent);
        
        multipart.addBodyPart(msgBodyPart);
        
        message.setContent(multipart);

        message.setSentDate(new Date());

        Transport.send(message);
}
                

class ForcedAuthenticator extends Authenticator {
        public PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(MailSettings.smtpUsername,
                                MailSettings.smtpPassword);
        }
}


Jack Wang


        

        
                
___________________________________________________________ 
Mp3疯狂搜-新歌热歌高速下
http://music.yahoo.com.cn/?source=mail_mailbox_footer

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to