2 Replies Latest reply on Nov 19, 2003 9:38 PM by mferreg

    mail service

    sys user Master

      Can anyone explain or give me an exemple on how to use the mail service (I'm using jboss 3.0.7)

        • 1. Re: mail service
          Andy Newbie

          In your code you can do something like this ...

          Context initial=new InitialContext();
          javax.mail.Session mail_session=(javax.mail.Session)initial.lookup("java:/comp/env/TheMailSession");

          javax.mail.Message msg=new MimeMessage(mail_session);
          msg.setFrom(new InternetAddress("your_email_address"));

          InternetAddress[] addrs=new InternetAddress[1];
          addrs[0] = new InternetAddress(recipient_email);
          msg.setSentDate(new java.util.Date());

          Multipart mp=new MimeMultipart();
          MimeBodyPart part=null;
          part = new MimeBodyPart();


          and then in the deployment descriptors add a block like this for the bean that uses the mail facilities in ejb-jar.xml

          and in jboss.cmp, you add

          <resource-manager res-class="javax.mail.Session">

          Simple! PS Dont forget to edit $JBOSS_HOME/server/default/deploy/mail-service.xml and put in the outgoing mail server name etc.

          • 2. Re: mail service
            mferreg Newbie

            When he says jboss.cmp I suppose it refers to META-INF/jboss.xml, I say it because I'm trying what the missage says and I've lost some time finding that file.

            Doing what is said here, I get an error NameNotFoundException: TheMailSession not found.

            Any Idea? I'm using jboss 3.2.1 - tomcat 4.1.24

            Thanks in advanced!