geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick McGuire <rick...@gmail.com>
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("someone@somewhere.com"));
      message.setRecipients(Message.RecipientType.TO, 
InternetAddress.parse("someone.else@somewhere.com"));
      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));
      messageBodyPart2.setFileName("xx.dat");
      Multipart multipart = new MimeMultipart();
      multipart.addBodyPart(messageBodyPart1);
      multipart.addBodyPart(messageBodyPart2);
      message.setContent(multipart);


>
> Cheers
>   Peter
>


Mime
View raw message