[mule-user] RE: send a file via email using smtp

264 views
Skip to first unread message

DIVYA KAMATH

unread,
May 14, 2012, 5:27:36 AM5/14/12
to us...@mule.codehaus.org
Hi,
I have changed my smtp configuration to this

<smtp:outbound-endpoint host="192.168.170.26 "
to="Admin...@test.com" subject="Please verify your account details" />
<email:string-to-email-transformer/>


It is connecting i think but i am getting the following exception.Is it a transformation problem?

Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.transport.email.transformers.StringToEmailMessage:59 (null)
2. null (java.lang.NullPointerException). Message payload is of type: String (org.mule.api.transformer.TransformerMessagingException)
org.mule.transformer.AbstractTransformer:123 (http://www.mulesoft.org/docs/site/cur...)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.transport.email.transformers.StringToEmailMessage.transformMessage(StringToEmailMessage.java:59)
at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:145)
at org.mule.transformer.AbstractMessageTransformer.transform(AbstractMessageTransformer.java:93)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Tomas Blohm

unread,
May 14, 2012, 7:10:34 AM5/14/12
to us...@mule.codehaus.org
What are you trying to achieve? Do you want to transform a string to suit the smtp transport? In that case the transformer should be before the smtp endpoint or referenced on the smtp endpoint.

/Tomas Blohm --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

DIVYA KAMATH

unread,
May 14, 2012, 7:24:34 AM5/14/12
to us...@mule.codehaus.org
Hi,
I just want to send the file via email.
so do i need to use the string to email transformer or can it be done witout transformation? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Tomas Blohm

unread,
May 14, 2012, 7:32:36 AM5/14/12
to us...@mule.codehaus.org
Do you want to send the file as attachment or file content as body?

/Tomas Blohm --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

DIVYA KAMATH

unread,
May 14, 2012, 7:40:34 AM5/14/12
to us...@mule.codehaus.org
Hi,
I would like to try both ways.
And when do we need to use the string to email transformer? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Tomas Blohm

unread,
May 14, 2012, 8:06:34 AM5/14/12
to us...@mule.codehaus.org
So, if the the payload is a file object and you want to send it as body you should use FileToString first, then StringToEmail. If the payload is InputStream you should use ObjectToString first, then StringToEmail. I can't see your config so I don't know if you use streaming or not, if you haven't disabled it you probably have InputStream as payload and should use the second approach.

/Tomas Blohm --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

DIVYA KAMATH

unread,
May 14, 2012, 8:24:34 AM5/14/12
to us...@mule.codehaus.org
Hi,
this is my config file


<spring:bean id="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method=
"shutdown">
<!-- <spring:property name="driverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<spring:property name="url" value="jdbc:derby:muleEmbeddedDB;create=true"/>-->
<spring:property name="driverName" value="oracle.jdbc.driver.OracleDriver"/>
<spring:property name="url" value="jdbc:oracle:thin:@itl-hw-132058d:1521:Prism"/>
<spring:property name="user" value="CS_ETL_TEST"/>
<spring:property name="password" value="cs_prism"/>

</spring:bean>

<file:connector name="input" autoDelete="false" pollingFrequency="4000" doc:name="File"/>

<jdbc:connector name="jdbcConnector" dataSource-ref="jdbcDataSource" pollingFrequency="1000" >
<jdbc:query key="storingfile" value="insert into transaction(amount) values (#[map-payload:amount])"></jdbc:query>

</jdbc:connector>

<!-- <jdbc:maps-to-xml-transformer name="XMLResponseTransformer"/>
<message-properties-transformer name="XMLContentTransformer">
<add-message-property key="Content-Type" value="text/xml"/>
</message-properties-transformer>
-->
<flow name="storingfile">
<file:inbound-endpoint path="D:\Alert1" connector-ref="input" doc:name="File" >

<file:filename-wildcard-filter pattern="*.xml"/>
</file:inbound-endpoint>
<jdbc:outbound-endpoint queryKey="storingfile" connector-ref="jdbcConnector"/>
</flow>


If i use inputstream as payload then i will need a java class for it which can take the inputstream as parameter in a function ? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Tomas Blohm

unread,
May 14, 2012, 8:34:34 AM5/14/12
to us...@mule.codehaus.org
Hi,

I don't see anything concerning sending email?

Anyway, if you use a object-to-string-transformer after the file inbound you will have the file content as string.
If you want to send that as email you should also add a string to email transformer before the smtp endpoint.

/Tomas Blohm --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

DIVYA KAMATH

unread,
May 15, 2012, 1:26:39 AM5/15/12
to us...@mule.codehaus.org
Hi,
Sorry i posted the wrong file.
My code is this

<flow name="fileflowFlow1" doc:name="fileflowFlow1">
<file:inbound-endpoint path="D:\Alert" connector-ref="input" doc:name="File" />
<echo-component doc:name="Echo"/>
<pooled-component>
<spring-object bean="testBpms"/>
</pooled-component>
<all>
<file:outbound-endpoint path="C:/Users/Divya_Kamath04/Desktop/EsperEvents" connector-ref="input" doc:name="File"/>
<file:outbound-endpoint path="C:/Users/Divya_Kamath04/Desktop/output" connector-ref="input" doc:name="File"/>
<amqp:outbound-endpoint queueName="response.queue" connector-ref="myamqpConnector"></amqp:outbound-endpoint>
<jdbc:outbound-endpoint queryKey="storingfile" connector-ref="jdbcConnector"/>
<smtp:outbound-endpoint host="192.168.170.26"
to="Admin...@test.com" subject="Please verify your account details" />

<!-- <email:string-to-email-transformer/>-->
</all>
</flow>


I did this and it send file contents in the body.
Ill try using the transformers to send it as email.
Thanks a ton for ur help :) --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Reply all
Reply to author
Forward
0 new messages