geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick McGuire <>
Subject Re: File attatchement in geronimo mail
Date Tue, 03 Oct 2006 17:48:22 GMT
Peter Petersson wrote:
> Im using Geronimo 1.1.1 and has just started to look into geronimo-mail.
> Is it posible to send a multipart mail with a file atatchement in the 
> current imp. of geronimo-mail ?
> In the case of yes any (code) examples out there explaining how to get 
> it done ?
Here's a simple example (essentially the same code axis uses to send a 
mime-encoded attachment):

      MimeMessage message = new MimeMessage(session);
      message.setFrom(new InternetAddress(""));
      message.setSubject("test subject");
      message.setText("test message");
      BodyPart messageBodyPart1 = new MimeBodyPart();
      messageBodyPart1.setText("part 1");
      BodyPart messageBodyPart2 = new MimeBodyPart();
      messageBodyPart1.setHeader("Content-Type", "text/plain");
      messageBodyPart1.setHeader("Content-Transfer-Encoding", "binary");
      messageBodyPart2.setHeader("Content-Type", "text/plain");
      messageBodyPart2.setHeader("Content-Transfer-Encoding", "binary");
      DataSource dataSource = new FileDataSource("xx.dat");
      messageBodyPart2.setDataHandler(new DataHandler(dataSource));
      Multipart multipart = new MimeMultipart();

> Cheers
>   Peter

View raw message