title: mule send email as an attachment
body: <p>My below code perfectly send email as an attachment, but the problem is </p>
  
  <p>1) payload is copying to the mail body. I want mail to be sent only as an attachment, don't want to include attachment in body part of the mail. </p>
  
  <p>2) email triggers twice always. I have given thread count as 1. Not sure from where the second event is triggering.</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;mule xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:context="http://www.springframework.org/schema/context"  xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
  http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
  http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
  http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
  http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
  http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
  http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd
  http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
  http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd"&gt;
      &lt;spring:beans&gt;
          &lt;context:property-placeholder location="accord.properties"/&gt;
          &lt;spring:bean id="transmission" class="com.creativeworld.service.InvokeTransmission"/&gt;
      &lt;/spring:beans&gt; 
      &lt;quartz:connector name="ABCQuartz" validateConnections="true" doc:name="ABC Quartz"&gt;
          &lt;quartz:factory-property key="org.quartz.scheduler.instanceName" value="ABC_XYZKReport"/&gt;
          &lt;quartz:factory-property key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool"/&gt;
          &lt;quartz:factory-property key="org.quartz.threadPool.threadCount" value="1"/&gt;
          &lt;quartz:factory-property key="org.quartz.scheduler.rmi.proxy" value="false"/&gt;
          &lt;quartz:factory-property key="org.quartz.scheduler.rmi.export" value="false"/&gt;
      &lt;/quartz:connector&gt;
      &lt;smtp:connector name="ABCSMTP" validateConnections="true" doc:name="SMTP" subject="ABC_XYZK Report"/&gt;
      &lt;flow name="flow1" doc:name="flow1" processingStrategy="synchronous"&gt;
          &lt;quartz:inbound-endpoint jobName="ABCQuartz" repeatInterval="180000"  responseTimeout="10000" connector-ref="ABCQuartz" doc:name="ABC XYZK"&gt;
              &lt;quartz:event-generator-job groupName="creativeworld" jobGroupName="creativeworld"&gt;
                  &lt;quartz:payload&gt;Creative World Quartz Scheduler.&lt;/quartz:payload&gt;
              &lt;/quartz:event-generator-job&gt;
          &lt;/quartz:inbound-endpoint&gt;
          &lt;scripting:component doc:name="Python"&gt;
              &lt;scripting:script engine="jython" file="ABC_XYZK.py"/&gt;
          &lt;/scripting:component&gt;
  
          &lt;set-session-variable variableName="outputfilepath" value="${OUTPUT_FILE}${FILE_NAME}-#[server.dateTime.format('${DATETIME_FORMAT}')]${FILE_TYPE}"  doc:name="File Name" /&gt;
          &lt;set-payload value="${COMMAND_PATH}#[' ']${DB_NAME}${OUTPUT_FILE}${URL}" doc:name="Transmission Commands"/&gt;
          &lt;set-payload value="#[message.payload]#[' -outputpath ']#[outputfilepath]" doc:name="Output Config"/&gt;
          &lt;invoke object-ref="transmission" method="invoke" methodArgumentTypes="java.lang.String" methodArguments="#[payload]" name="transmissionAPI"/&gt;
          &lt;vm:outbound-endpoint exchange-pattern="one-way" path="smtp" doc:name="VM"/&gt;
      &lt;/flow&gt;
      &lt;flow name="smtp" doc:name="smtp" processingStrategy="synchronous"&gt;
          &lt;vm:inbound-endpoint exchange-pattern="one-way" path="smtp" doc:name="VM"/&gt;
          &lt;scripting:component doc:name="Groovy"&gt;
              &lt;scripting:script engine="Groovy"&gt;&lt;![CDATA[new File(sessionVars['outputfilepath']).text]]&gt;&lt;/scripting:script&gt;
          &lt;/scripting:component&gt;
          &lt;set-attachment attachmentName="${FILE_NAME}-#[server.dateTime.format('${DATETIME_FORMAT}')]${FILE_TYPE}" value="#[payload]" contentType="text/plain" doc:name="ABC_XYZK Report"/&gt;
          &lt;smtp:outbound-endpoint host="mailrelay.ad.corp.local" responseTimeout="10000" doc:name="SMTP" connector-ref="ABCSMTP" mimeType="text/plain" from="mymailid@mycompany.com"  subject="ABC_XYZK" to="mymailid@mycompany.com"&gt;
              &lt;!-- &lt;email:email-to-string-transformer/&gt; --&gt;
          &lt;/smtp:outbound-endpoint&gt;
      &lt;/flow&gt;
  </code></pre>