Thanks,
Marc
2005/11/22, Ralph Goers <[EMAIL PROTECTED]>:
First, read http://cocoon.apache.org/community/contrib.html.
Unfortunately, this still references bugzilla which the project no
longer uses. Instead, go to http://issues.apache.org/jira/browse/COCOON
and create a new issue. You will probably need to create an account in
Jira before you can create the issue.
We appreciate your work. Thanks.
Ralph
Marc Salvetti wrote:
> Answering to myself again :)
>
> I finally managed to do it, but i had to patch the mail block.
> I changed 3 files :
> MailMessageSender.java
> MailSender.java
> SendMail.java
>
> Basically, i added a "bodyMimeType" parameter to the action, and
> checked if this attribute is set, use the setContent(body, mimeType)
> method rather than the setText(body, charset) method.
>
> It works fine, and i would like to contribute the fix, but since i'm
> not a commiter, i don't know how to do
>
> Marc
>
> 2005/11/21, Marc Salvetti <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>>:
>
>
>
> 2005/11/21, Marc Salvetti <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>>:
>
> That's why i'm trying to do for a while now and i came to the
> following problems :
>
> - if i use the action and set the src attribute to a cocoon
> pipeline producing html, the Content-disposition = attachment
> header is added, which i don't want (i want the html inline),
> but the pdf file is attached correctly to the mail
> - I can manage to send the html inline using the javaMail api
> directly from flowscript, but authentication and construction
> of the message is more complex than using the action, and i
> get the following error when sending the message :
>
> ERROR 2005-11-21 19:57:05,710 [flow] Thread-108 -
> javax.mail.MessagingException: IOException while sending message;
> nested exception is:
> javax.activation.UnsupportedDataTypeException : no object
> DCH for MIME type application/pdf
>
>
> I looked at the code of the MessageSender class, and i saw
> that it get the mime type by using the sourceResolver component.
> Since the mime type returned by the sourceResolver is also
> application/pdf i know it's not something to do with versions
> of the activation framework or some
>
>
> Sorry, i sent the message by mistake - damn keyboards shortcuts ! :)
>
> Since the mime type returned by the sourceResolver is also
> application/pdf i think it's not something to do with versions of
> the activation framework or something like that, but more with the
> way i use the api.
>
> I'd rather use the action, but it doesn't support adding custom
> headers, and it set the body of the message as an attachment.
>
> here is the flowscript i use :
>
> var mailprops = new java.util.Properties();
> mailprops.put("mail.smtp.host", cocoon.parameters['smtp-host']);
> mailprops.put("mail.smtp.auth", "true");
> mailprops.put("mail.smtp.user", cocoon.parameters['smtp-user']);
> mailprops.put("mail.smtp.password",
> cocoon.parameters['smtp-password']);
> var session = javax.mail.Session.getDefaultInstance(mailprops,
> null);
> session.setDebug(true);
> // create a message
> var msg = new javax.mail.internet.MimeMessage(session);
> msg.setRecipients(javax.mail.Message.RecipientType.TO
> < http://javax.mail.Message.RecipientType.TO>, to);
> if(!bcc.equals("")){
> msg.setRecipients(javax.mail.Message.RecipientType.BCC, bcc);
> }
> // Optional : You can also set your custom headers in the
> Email if you Want
> // Setting the Subject and Content Type
> msg.setSubject(subject);
> msg.setSentDate(new java.util.Date());
> var result, message;
> try
> {
> var addressFrom = new
> javax.mail.internet.InternetAddress(cocoon.parameters['from']);
> msg.setFrom(addressFrom);
>
> // create and fill the first message part
> var mbp1 = new javax.mail.internet.MimeBodyPart();
> mbp1.setContent(body, "text/html");
>
> // create the Multipart and its parts to it
> var mp = new javax.mail.internet.MimeMultipart();
> mp.addBodyPart(mbp1);
>
> if(!attachments.equals("")){
> // create and fill the second message part
> var mbp2 = new javax.mail.internet.MimeBodyPart();
> mbp2.setDisposition("attachment")
> var mimeType = getMimeType(attachments);
> // Use setText(text, charset), to show it off !
> var stream = new java.io.ByteArrayOutputStream();
> cocoon.processPipelineTo(attachments, {}, stream );
>
> mbp2.setContent(stream, mimeType);
> mp.addBodyPart(mbp2);
> }
>
> // add the Multipart to the message
> msg.setContent(mp);
>
> // send the message
> //javax.mail.Transport.send(msg);
> var tr = session.getTransport("smtp");
> tr.connect(cocoon.parameters['smtp-host'],
> cocoon.parameters['smtp-user'], cocoon.parameters['smtp-password']);
> msg.saveChanges();
> tr.sendMessage(msg, msg.getAllRecipients());
> tr.close();
> result = "success";
> }
> catch(e)
> {
> cocoon.log.error("e="+ e);
> result = "failure";
> message = e;
> }
>
>
> Any help would be greatly appreciated !
>
> Marc
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
