cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric SCHAEFFER" <eschaef...@posterconseil.com>
Subject Re: attachments
Date Fri, 19 May 2000 08:08:44 GMT
   // Send e-mail
   Properties mailProperties = new Properties();
   mailProperties.put("mail.smtp.host", "<your_host>");
   javax.mail.Session mailSession =
javax.mail.Session.getDefaultInstance(mailProperties, null);
   javax.mail.internet.MimeMessage msg = new
javax.mail.internet.MimeMessage(mailSession);
   javax.mail.internet.InternetAddress fromAddr = new
javax.mail.internet.InternetAddress("<your_email>", "<optional_name>");
   msg.setFrom(fromAddr);
   javax.mail.internet.InternetAddress[] replyAddrs = {
    new javax.mail.internet.InternetAddress("<email>", "<optional_name>")
    };
   msg.setReplyTo(replyAddrs);
   javax.mail.internet.InternetAddress[] toAddrs = {
    new javax.mail.internet.InternetAddress("<email>", "<optional_name>")
    };
   msg.setRecipients(javax.mail.Message.RecipientType.TO, toAddrs);
   msg.setSubject("<mail_subject>");

   // msg content
// Alternative HTML / text
   javax.mail.internet.MimeMultipart msgAlternativeContent = new
javax.mail.internet.MimeMultipart();
   msgAlternativeContent.setSubType("alternative");
   javax.mail.internet.MimeBodyPart msgPart = null;
   msgPart = new javax.mail.internet.MimeBodyPart();
   msgPart.setContent("<html_content>", "text/html");
   msgAlternativeContent.addBodyPart(msgPart);
   msgPart = new javax.mail.internet.MimeBodyPart();
   msgPart.setContent("<plain_text_content>", "text/plain");
   msgAlternativeContent.addBodyPart(msgPart);
   msg.setContent(msgAlternativeContent);

/* or to attach a file
   javax.mail.internet.MimeMultipart msgContent = new
javax.mail.internet.MimeMultipart();
   javax.mail.internet.MimeBodyPart msgPart = null;
   msgPart = new javax.mail.internet.MimeBodyPart();
   msgPart.setContent("<plain_text_content>", "text/plain");
   msgContent.addBodyPart(msgPart);
   msgPart = new javax.mail.internet.MimeBodyPart();
   msgPart.setContent(msgAlternativeContent);
   msgContent.addBodyPart(msgPart);
   msgPart = new javax.mail.internet.MimeBodyPart();
   javax.activation.FileDataSource fileDSrc = new
javax.activation.FileDataSource("<file_path>");
   msgPart.setDataHandler(new javax.activation.DataHandler(fileDSrc));
   msgPart.setFileName("<file_name_to_appear_in_attachement>");
   msgContent.addBodyPart(msgPart);
   msg.setContent(msgContent);
*/

   javax.mail.Transport.send(msg);

----- Original Message -----
From: Nishit Trivedi <nishit@planet.net>
To: <cocoon-users@xml.apache.org>
Sent: Thursday, May 18, 2000 6:53 PM
Subject: attachments


> hi,
> does anybody know how to send attachment with javamail-cocoon...
> i am using:
> cocoon1.7.2
> javamail1.1.3
>
> Internet Programmer
> Planet Access Networks
> 973-691-4704 Ext:157
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


Mime
View raw message