如何删除电子邮件流中的附件中的附件?

时间:2016-03-06 03:09:55

标签: mule email-attachments

我试图删除附件,以便我的出站电子邮件只包含有效负载。我使用附件变压器,但即使我使用“*”作为滤波器,仍然会发送附件。我已将它放在入站端点和出站端点上,但是电子邮件上的附件仍然存在

 <remove-attachment attachmentName="&quot;*&quot;" doc:name="Attachment"/>


<flow name="ocr_app_testFlow">
    <pop3:inbound-endpoint host="mail.awh.com.au" user="knaufack" password="ocr123" responseTimeout="10000" doc:name="POP3"/>
    <logger message="#[message.inboundProperties.subject]" level="INFO" doc:name="Logger"/>
    <remove-attachment attachmentName="*" doc:name="Attachment"/>
    <choice doc:name="Choice">
        <when expression="#[wildcard('*Succeeded*',message.inboundProperties.subject)]">
            <set-variable variableName="Subject" value="#[message.inboundProperties.subject]" doc:name="Variable"/>
            <set-variable variableName="Warehouse" value="#[message.inboundProperties.subject.substring(40,43)]" doc:name="Variable"/>
            <set-variable variableName="Order" value="#[message.inboundProperties.subject.substring(44,51)]" doc:name="Variable"/>
        </when>
        <otherwise>
            <set-variable variableName="Subject" value="#[message.inboundProperties.subject]" doc:name="Variable"/>
            <set-variable variableName="Warehouse" value="#[message.inboundProperties.subject.substring(37,40)]" doc:name="Variable"/>
            <set-variable variableName="Order" value="#[message.inboundProperties.subject.substring(41,48)]" doc:name="Variable"/>
        </otherwise>
    </choice>
    <logger message="#[flowVars.Order] from #[flowVars.Warehouse]" level="INFO" doc:name="Logger"/>
    <set-payload value="Your Order #[flowVars.Order] from #[flowVars.Warehouse] Warehouse is imported succesfully. Please Verify" doc:name="Set Payload"/>
    <remove-attachment attachmentName="*" doc:name="Attachment"/>
    <choice doc:name="Choice">
        <when expression="#[flowVars.Warehouse  == 'ROC']">
            <smtp:outbound-endpoint host="mail.awh.com.au" user="tupload" password="upload123" to="tupload@awh.com.au" from="AWH_Logistics_Integration" subject="AWH OCR Process Notification" responseTimeout="10000" doc:name="ROC Warehouse"/>
        </when>
        <otherwise>
            <smtp:outbound-endpoint host="mail.awh.com.au" user="tupload" password="upload123" to="pauldominguez@awh.com.au" from="AWH_Logistics_Integration" subject="AWH OCR Process Notification" responseTimeout="10000" doc:name="SMTP"/>
        </otherwise>
    </choice>
</flow>

1 个答案:

答案 0 :(得分:0)

  1. 将附加的变换器类添加到项目中。
  2. package org.awh.pfinder;
    
    import org.mule.transport.email.transformers.ObjectToMimeMessage;
    
    public class RemoveAttachmentTransformer extends ObjectToMimeMessage {
        
        public RemoveAttachmentTransformer() {
            super();
            setUseInboundAttachments(false);
        }
    
    }

    1. 添加SMTP连接器并将该转换器设置为出站转换器:      
相关问题