You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Pierre Goupil <go...@gmail.com> on 2007/08/21 17:44:58 UTC

[noob] e-mail : setting the content-type of the body

Hello all,

I'm currently playing around with commons e-mail. I'm using it to send
e-mails to a server with a WDDX body and some file attachements. FYI WDDX is
a sub-set of XML from Macromedia / Allaire.

It all works fine except for one thing : I would like to be able to tell to
the server (which will be dealing with the e-mail) that the body is WDDX.

Is there a way to achieve this ? I've tried with :
email.setSubType("application/wddx")
but it gives me a parse exception.

Thanks in advance,

Pierre

Re: [noob] e-mail : setting the content-type of the body

Posted by Pierre Goupil <go...@gmail.com>.
Thanx a lot for this clue ! Now I get another exception (
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type
application/wddx) and according to people using java mail on the net, it is
a problem of me having different versions for activation.jar & mail.jar. I'm
going to fix this (and maybe my commons-email.jar as well) and I will tell
you more.


Cheers,


Pierre



2007/8/22, Ben Speakmon <bs...@apache.org>:
>
> Ah, I see.
>
> MultiPartEmail.setSubType() sets the MIME subtype of the parent
> MimeMultipart container. Every MultiPartEmail and HtmlEmail object is
> built
> around a multipart/mixed or multipart/related. It's breaking for you
> because
> you're trying to set the content type to "multipart/application/wdxx", and
> that's obviously not going to work. You probably don't want to call that
> method at all.
>
> I assume you want the WDXX part to be the "content" of the message, not
> one
> of the attachments. Try Email.setContent(Object o, String contentType) and
> specify the content type as application/wddx. Let me know how that works.
>
> --Ben
>
> On 8/22/07, Pierre Goupil <go...@gmail.com> wrote:
> >
> > Hello,
> >
> > Sure. Here it is :
> >
> > **************************************
> > org.apache.commons.mail.EmailException: Sending the email to the
> following
> > server failed : smtp.orange.fr:25
> >     at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)
> >     at org.apache.commons.mail.Email.send(Email.java:898)
> >     at com.gossinteractive.templates.contribute.ContributeBean.sendMail(
> > ContributeBean.java:736)
> >     at
> > com.gossinteractive.templates.contribute.ContributeBean.processFiles(
> > ContributeBean.java:656)
> >     at com.gossinteractive.templates.contribute.ContributeBean.start(
> > ContributeBean.java:84)
> >     at com.gossinteractive.icm4j.Icm4jContext.addAndExecuteAction(
> > Icm4jContext.java:449)
> >     at com.gossinteractive.icm4j.Icm4jContext.loadAndExecuteActions(
> > Icm4jContext.java:493)
> >     at com.gossinteractive.icm4j.Icm4jContext.start(Icm4jContext.java
> > :1336)
> >     at com.gossinteractive.icm4j.jsf.Icm4jJsfServlet.forwardRequest(
> > Icm4jJsfServlet.java:128)
> >     at com.gossinteractive.icm4j.http.Icm4jHttpServlet.doWork(
> > Icm4jHttpServlet.java:269)
> >     at com.gossinteractive.icm4j.http.Icm4jHttpServlet.doPost(
> > Icm4jHttpServlet.java:312)
> >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> >     at com.gossinteractive.icm4j.http.Icm4jHttpServlet.service(
> > Icm4jHttpServlet.java:366)
> >     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> > ApplicationFilterChain.java:269)
> >     at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> > ApplicationFilterChain.java:188)
> >     at org.apache.catalina.core.StandardWrapperValve.invoke(
> > StandardWrapperValve.java:210)
> >     at org.apache.catalina.core.StandardContextValve.invoke(
> > StandardContextValve.java:174)
> >     at org.apache.catalina.core.StandardHostValve.invoke(
> > StandardHostValve.java:127)
> >     at org.apache.catalina.valves.ErrorReportValve.invoke(
> > ErrorReportValve.java:117)
> >     at org.apache.catalina.core.StandardEngineValve.invoke(
> > StandardEngineValve.java:108)
> >     at org.apache.catalina.connector.CoyoteAdapter.service(
> > CoyoteAdapter.java:151)
> >     at org.apache.coyote.http11.Http11Processor.process(
> > Http11Processor.java
> > :870)
> >     at
> >
> >
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> > (Http11BaseProtocol.java:665)
> >     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> > PoolTcpEndpoint.java:528)
> >     at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
> > LeaderFollowerWorkerThread.java:81)
> >     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
> > ThreadPool.java:685)
> >     at java.lang.Thread.run(Thread.java:595)
> > Caused by: javax.mail.internet.ParseException
> >     at javax.mail.internet.ParameterList.<init>(ParameterList.java:81)
> >     at javax.mail.internet.ContentType.<init>(ContentType.java:82)
> >     at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java
> > :1108)
> >     at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java
> > :1930)
> >     at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java
> :1911)
> >     at javax.mail.Transport.send(Transport.java:79)
> >     at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)
> >     ... 27 more
> >
> > **************************************
> >
> > Unfortunately, it doesn't want to display a longer stacktrace.
> >
> > Again, this exception occurs only when performing an
> > "email.setSubType("application/wddx")".
> > Without it, the e-mail is sent, but it seems that my processing back-end
> > needs it.
> >
> > I hope this helps you to help me :)
> >
> > Pierre
> >
> >
> >
> >
> >
> > 2007/8/21, Ben Speakmon <bs...@apache.org>:
> > >
> > > Hi Pierre,
> > >
> > > Can you post the actual exception you get when you try it?
> > >
> > > --Ben
> > >
> > > On 8/21/07, Pierre Goupil <go...@gmail.com> wrote:
> > > >
> > > > Hello all,
> > > >
> > > > I'm currently playing around with commons e-mail. I'm using it to
> send
> > > > e-mails to a server with a WDDX body and some file attachements. FYI
> > > WDDX
> > > > is
> > > > a sub-set of XML from Macromedia / Allaire.
> > > >
> > > > It all works fine except for one thing : I would like to be able to
> > tell
> > > > to
> > > > the server (which will be dealing with the e-mail) that the body is
> > > WDDX.
> > > >
> > > > Is there a way to achieve this ? I've tried with :
> > > > email.setSubType("application/wddx")
> > > > but it gives me a parse exception.
> > > >
> > > > Thanks in advance,
> > > >
> > > > Pierre
> > > >
> > >
> >
> >
> >
> > --
> > "Si le sang ne coule pas assez chaud dans tes veines,
> > je le répandrais sur le sable pour qu'il bouille au soleil."
> >
> > (Maraxus de Kelde)
> >
>



-- 
"Si le sang ne coule pas assez chaud dans tes veines,
je le répandrais sur le sable pour qu'il bouille au soleil."

(Maraxus de Kelde)

Re: [noob] e-mail : setting the content-type of the body

Posted by Ben Speakmon <bs...@apache.org>.
Ah, I see.

MultiPartEmail.setSubType() sets the MIME subtype of the parent
MimeMultipart container. Every MultiPartEmail and HtmlEmail object is built
around a multipart/mixed or multipart/related. It's breaking for you because
you're trying to set the content type to "multipart/application/wdxx", and
that's obviously not going to work. You probably don't want to call that
method at all.

I assume you want the WDXX part to be the "content" of the message, not one
of the attachments. Try Email.setContent(Object o, String contentType) and
specify the content type as application/wddx. Let me know how that works.

--Ben

On 8/22/07, Pierre Goupil <go...@gmail.com> wrote:
>
> Hello,
>
> Sure. Here it is :
>
> **************************************
> org.apache.commons.mail.EmailException: Sending the email to the following
> server failed : smtp.orange.fr:25
>     at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)
>     at org.apache.commons.mail.Email.send(Email.java:898)
>     at com.gossinteractive.templates.contribute.ContributeBean.sendMail(
> ContributeBean.java:736)
>     at
> com.gossinteractive.templates.contribute.ContributeBean.processFiles(
> ContributeBean.java:656)
>     at com.gossinteractive.templates.contribute.ContributeBean.start(
> ContributeBean.java:84)
>     at com.gossinteractive.icm4j.Icm4jContext.addAndExecuteAction(
> Icm4jContext.java:449)
>     at com.gossinteractive.icm4j.Icm4jContext.loadAndExecuteActions(
> Icm4jContext.java:493)
>     at com.gossinteractive.icm4j.Icm4jContext.start(Icm4jContext.java
> :1336)
>     at com.gossinteractive.icm4j.jsf.Icm4jJsfServlet.forwardRequest(
> Icm4jJsfServlet.java:128)
>     at com.gossinteractive.icm4j.http.Icm4jHttpServlet.doWork(
> Icm4jHttpServlet.java:269)
>     at com.gossinteractive.icm4j.http.Icm4jHttpServlet.doPost(
> Icm4jHttpServlet.java:312)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>     at com.gossinteractive.icm4j.http.Icm4jHttpServlet.service(
> Icm4jHttpServlet.java:366)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:269)
>     at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:188)
>     at org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:210)
>     at org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:174)
>     at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:127)
>     at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java:117)
>     at org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:108)
>     at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java:151)
>     at org.apache.coyote.http11.Http11Processor.process(
> Http11Processor.java
> :870)
>     at
>
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> (Http11BaseProtocol.java:665)
>     at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> PoolTcpEndpoint.java:528)
>     at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
> LeaderFollowerWorkerThread.java:81)
>     at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
> ThreadPool.java:685)
>     at java.lang.Thread.run(Thread.java:595)
> Caused by: javax.mail.internet.ParseException
>     at javax.mail.internet.ParameterList.<init>(ParameterList.java:81)
>     at javax.mail.internet.ContentType.<init>(ContentType.java:82)
>     at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java
> :1108)
>     at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java
> :1930)
>     at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1911)
>     at javax.mail.Transport.send(Transport.java:79)
>     at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)
>     ... 27 more
>
> **************************************
>
> Unfortunately, it doesn't want to display a longer stacktrace.
>
> Again, this exception occurs only when performing an
> "email.setSubType("application/wddx")".
> Without it, the e-mail is sent, but it seems that my processing back-end
> needs it.
>
> I hope this helps you to help me :)
>
> Pierre
>
>
>
>
>
> 2007/8/21, Ben Speakmon <bs...@apache.org>:
> >
> > Hi Pierre,
> >
> > Can you post the actual exception you get when you try it?
> >
> > --Ben
> >
> > On 8/21/07, Pierre Goupil <go...@gmail.com> wrote:
> > >
> > > Hello all,
> > >
> > > I'm currently playing around with commons e-mail. I'm using it to send
> > > e-mails to a server with a WDDX body and some file attachements. FYI
> > WDDX
> > > is
> > > a sub-set of XML from Macromedia / Allaire.
> > >
> > > It all works fine except for one thing : I would like to be able to
> tell
> > > to
> > > the server (which will be dealing with the e-mail) that the body is
> > WDDX.
> > >
> > > Is there a way to achieve this ? I've tried with :
> > > email.setSubType("application/wddx")
> > > but it gives me a parse exception.
> > >
> > > Thanks in advance,
> > >
> > > Pierre
> > >
> >
>
>
>
> --
> "Si le sang ne coule pas assez chaud dans tes veines,
> je le répandrais sur le sable pour qu'il bouille au soleil."
>
> (Maraxus de Kelde)
>

Re: [noob] e-mail : setting the content-type of the body

Posted by Pierre Goupil <go...@gmail.com>.
Hello,

Sure. Here it is :

**************************************
org.apache.commons.mail.EmailException: Sending the email to the following
server failed : smtp.orange.fr:25
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:873)
    at org.apache.commons.mail.Email.send(Email.java:898)
    at com.gossinteractive.templates.contribute.ContributeBean.sendMail(
ContributeBean.java:736)
    at com.gossinteractive.templates.contribute.ContributeBean.processFiles(
ContributeBean.java:656)
    at com.gossinteractive.templates.contribute.ContributeBean.start(
ContributeBean.java:84)
    at com.gossinteractive.icm4j.Icm4jContext.addAndExecuteAction(
Icm4jContext.java:449)
    at com.gossinteractive.icm4j.Icm4jContext.loadAndExecuteActions(
Icm4jContext.java:493)
    at com.gossinteractive.icm4j.Icm4jContext.start(Icm4jContext.java:1336)
    at com.gossinteractive.icm4j.jsf.Icm4jJsfServlet.forwardRequest(
Icm4jJsfServlet.java:128)
    at com.gossinteractive.icm4j.http.Icm4jHttpServlet.doWork(
Icm4jHttpServlet.java:269)
    at com.gossinteractive.icm4j.http.Icm4jHttpServlet.doPost(
Icm4jHttpServlet.java:312)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
    at com.gossinteractive.icm4j.http.Icm4jHttpServlet.service(
Icm4jHttpServlet.java:366)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(
StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(
StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(
StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(
ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(
StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(
CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:870)
    at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
ThreadPool.java:685)
    at java.lang.Thread.run(Thread.java:595)
Caused by: javax.mail.internet.ParseException
    at javax.mail.internet.ParameterList.<init>(ParameterList.java:81)
    at javax.mail.internet.ContentType.<init>(ContentType.java:82)
    at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java
:1108)
    at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:1930)
    at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:1911)
    at javax.mail.Transport.send(Transport.java:79)
    at org.apache.commons.mail.Email.sendMimeMessage(Email.java:863)
    ... 27 more

**************************************

Unfortunately, it doesn't want to display a longer stacktrace.

Again, this exception occurs only when performing an
"email.setSubType("application/wddx")".
Without it, the e-mail is sent, but it seems that my processing back-end
needs it.

I hope this helps you to help me :)

Pierre





2007/8/21, Ben Speakmon <bs...@apache.org>:
>
> Hi Pierre,
>
> Can you post the actual exception you get when you try it?
>
> --Ben
>
> On 8/21/07, Pierre Goupil <go...@gmail.com> wrote:
> >
> > Hello all,
> >
> > I'm currently playing around with commons e-mail. I'm using it to send
> > e-mails to a server with a WDDX body and some file attachements. FYI
> WDDX
> > is
> > a sub-set of XML from Macromedia / Allaire.
> >
> > It all works fine except for one thing : I would like to be able to tell
> > to
> > the server (which will be dealing with the e-mail) that the body is
> WDDX.
> >
> > Is there a way to achieve this ? I've tried with :
> > email.setSubType("application/wddx")
> > but it gives me a parse exception.
> >
> > Thanks in advance,
> >
> > Pierre
> >
>



-- 
"Si le sang ne coule pas assez chaud dans tes veines,
je le répandrais sur le sable pour qu'il bouille au soleil."

(Maraxus de Kelde)

Re: [noob] e-mail : setting the content-type of the body

Posted by Ben Speakmon <bs...@apache.org>.
Hi Pierre,

Can you post the actual exception you get when you try it?

--Ben

On 8/21/07, Pierre Goupil <go...@gmail.com> wrote:
>
> Hello all,
>
> I'm currently playing around with commons e-mail. I'm using it to send
> e-mails to a server with a WDDX body and some file attachements. FYI WDDX
> is
> a sub-set of XML from Macromedia / Allaire.
>
> It all works fine except for one thing : I would like to be able to tell
> to
> the server (which will be dealing with the e-mail) that the body is WDDX.
>
> Is there a way to achieve this ? I've tried with :
> email.setSubType("application/wddx")
> but it gives me a parse exception.
>
> Thanks in advance,
>
> Pierre
>