Rick McGuire wrote:
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):
Thanks Rick I just noticed the geronimo-activation spec :) It whas the
part I whas missing.
Peter
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[EMAIL PROTECTED]"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[EMAIL PROTECTED]"));
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