Using the emailer application attached to end of this mail - I'am sending text/plain 
and text/html multipart messages containing non-ascii (danish) characters.

When executed inside NetBeans, mails get encoded as expected.

But my EmailerMDB uses exactly the same code for sending emails and executed inside 
the JBoss container produces incorrect email messages.
Non-ascii characters are not encoded as expected.

Does anybody know if there is some property that needs to be set at server startup?
Or is there something else I have not been aware of?

Regards

Andreas

================================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /usr/local/jboss/home

  JAVA: /Library/Java/Home/bin/java

  JAVA_OPTS:  -Dprogram.name=run.sh -Dfile.encoding=UTF-8

  CLASSPATH: /usr/local/jboss/home/bin/run.jar:/Library/Java/Home/lib/tools.jar

================================================================================

00:29:25,163 INFO  [Server] Starting JBoss (MX MicroKernel)...
00:29:25,167 INFO  [Server] Release ID: JBoss [WonderLand] 3.2.3 (build: 
CVSTag=JBoss_3_2_3 date=200311301445)
00:29:25,652 INFO  [ServerInfo] Java version: 1.4.2_01,Apple Computer, Inc.
00:29:25,653 INFO  [ServerInfo] Java VM: Java HotSpot(TM) Client VM 
1.4.2-001-31,"Apple Computer, Inc."
00:29:25,654 INFO  [ServerInfo] OS-System: Mac OS X 10.3.2,ppc



/*
 * MailSender2.java
 *
 * Created on February 25, 2004, 9:27 PM
 */

package xpetstore.util;

import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import javax.activation.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.swing.*;


/**
 *
 * @author  andreas
 */
public class MailSender2 extends JFrame implements ActionListener {
    
    JTextField field = new JTextField();
    JButton button = new JButton("Send");
    
    public MailSender2() {
        getContentPane().setLayout(new BorderLayout());
        getContentPane().add("Center", field);
        getContentPane().add("South", button);
        button.addActionListener(this);
        String s = "Hvis du ikke kan lÃ|se denne e-mail, "
        .concat("kan det skyldes, at dit e-mail-program ikke kan lÃ|se HTML.\nDu har 
")
        .concat("mulighed for at modtage e-mailen som almindelig tekst, ")
        .concat("hvis du Ã|ndrer dine indstillinger ")
        .concat("http://prispiraten.kgbinternet.com/ppwebshop/signon.jspa";);
        
        field.setText(s);
    }
    
    public void actionPerformed(ActionEvent ev) {
        if (ev.getSource() == button) {
            String text = field.getText();
            send(text);
        }
    }
    
    void send(String msg) {
        try {
            Properties props = new Properties();
            props.put("mail.smtp.host", "mail.tiscali.dk");
            Session session = Session.getDefaultInstance(props, null);
            session.setDebug(true);
            
            MimeMessage message = new MimeMessage( session );
            ByteArrayInputStream is = new ByteArrayInputStream(msg.getBytes());
            MimeBodyPart plaintext = new MimeBodyPart( );
            plaintext.setContent(msg, "text/plain; charset=\"UTF-8\"");
            
            
            MimeBodyPart htmltext = new MimeBodyPart( );
            htmltext.setContent(
                EmailMessages.getWelcomeMessage("ÃÂÃÂÃÂ Ã? ÃÂ ÃÂ"),
                "text/html; charset=\"UTF-8\""
            );
            
            Multipart mp = new MimeMultipart("alternative"); // result -> 
multipart/alternative
            mp.addBodyPart( plaintext );
            mp.addBodyPart( htmltext );
            message.setContent( mp );
            message.saveChanges();
            
            InternetAddress from = new InternetAddress("[EMAIL PROTECTED]");
            message.setFrom(from);
            InternetAddress[] recipients = {new InternetAddress("[EMAIL PROTECTED]")};
            message.setRecipients(Message.RecipientType.TO, recipients);
            message.setSubject("RÃÂdgrÃÂd med flÃÂde", "UTF-8");
            
            System.out.println(message.getContentType());
            System.out.println(message.getSize());
            System.out.println(message.getEncoding());
            System.out.println(message.getContent().getClass());
            System.out.println(message.getContent()); // does not work if setContent 
is not called.
            
            System.out.println("----");
            System.out.println(message.getDataHandler());
            System.out.println(message.getDataHandler().getContent());
            System.out.println(message.getDataHandler().getDataSource());
            
System.out.println(message.getDataHandler().getDataSource().getContentType());
            
            message.writeTo(System.out);
            
            message.writeTo( new PrintStream(
                new FileOutputStream("/tmp/mailtest.txt"), true, "UTF-8")
            );
            
            Transport.send(message);
            
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    
    public static void main(String[] args) {
        MailSender mailSender = new MailSender();
        mailSender.setSize(200, 200);
        mailSender.show();
    }   
}

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3823005#3823005

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3823005


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to