View Javadoc

1   /*
2    * $Id: AddOutboundAttachments.java 20238 2010-11-18 05:43:38Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.email.transformers;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.transformer.TransformerException;
15  import org.mule.transformer.AbstractMessageTransformer;
16  
17  public class AddOutboundAttachments extends AbstractMessageTransformer
18  {
19      @Override
20      public Object transformMessage(MuleMessage msg, String outputEncoding) throws TransformerException
21      {
22          try
23          {
24              msg.addOutboundAttachment("seeya", "seeya", "application/text");
25              msg.addOutboundAttachment("goodbye", "goodbye", "application/xml");
26          }
27          catch (Exception e)
28          {
29              throw new TransformerException(this, e);
30          }
31          return msg.getPayload();
32      }
33  }
34