Dear Vinith,
Sorry, these are for version 1.4.3. Here is the excerpt of the config
file that emails the attachment.
<mule-descriptor name="GGEmailOrders"
implementation="org.mule.components.simple.PassThroughComponent">
<inbound-router>
<endpoint
address="vm://gargoyle.orders.email" />
</inbound-router>
<outbound-router>
<router
className="org.mule.routing.outbound.OutboundPassThroughRouter">
<endpoint
address="smtp://${smtp.host}?address=${salesorder.toAddress}"
transformers="ObjectToEmailMessage GGMailContentsToAttachment" />
</router>
</outbound-router>
</mule-descriptor>
Regards,
Wayne Wundram
-----Original Message-----
From: VinithGowda [mailto:
vinith.hr@...]
Sent: Friday, July 04, 2008 8:48 AM
To:
user@...
Subject: RE: [mule-user] Attach File to E-mail (SMTP)
To be more clear with you I am using Mule 2.x
Thanks
Vinith Gowda
Wayne Wundram wrote:
>
> I created a Transformer that takes the content of the message and
> attaches it to an email. The code of my transformer is:
>
>
>
> /*
>
> * To change this template, choose Tools | Templates
>
> * and open the template in the editor.
>
> */
>
>
>
> package miraculum.mule;
>
>
>
> import java.io.IOException;
>
> import javax.mail.Message;
>
> import javax.mail.MessagingException;
>
> import javax.mail.Multipart;
>
> import javax.mail.internet.MimeBodyPart;
>
> import javax.mail.internet.MimeMessage;
>
> import javax.mail.internet.MimeMultipart;
>
> import org.apache.log4j.Logger;
>
> import org.mule.transformers.AbstractTransformer;
>
> import org.mule.umo.transformer.TransformerException;
>
> import org.mule.util.DateUtils;
>
>
>
> /**
>
> *
>
> * @author Wayne Wundram
>
> *
>
> * Mule Transformer to take the contents of a Mail Message
>
> * and send it as an attachment.
>
> *
>
> */
>
> public class TfmMailContentsToAttachment extends AbstractTransformer {
>
> private String attachmentName;
>
> public static final String DEFAULT_DATE_FORMAT =
> "yyyy-MM-dd_HH-mm-ss.SSS";
>
>
>
> static Logger log =
> Logger.getLogger(TfmMailContentsToAttachment.class.getName());
>
>
>
> public TfmMailContentsToAttachment() {
>
> super();
>
> this.registerSourceType(Message.class);
>
> this.setReturnClass(Message.class);
>
> }
>
>
>
> public Object doTransform(Object src, String encoding) throws
> TransformerException {
>
>
>
> MimeMessage inputMessage = (MimeMessage) src;
>
>
>
> // If the attachmentName property is not set then default it.
>
> if (getAttachmentName() == null) {
>
> setAttachmentName("attachment.txt");
>
> }
>
> String generatedName = getAttachmentName();
>
> if (generatedName.indexOf("{DATE}") > -1) {
>
> String currentDate =
> DateUtils.getTimeStamp(DEFAULT_DATE_FORMAT);
>
> generatedName = generatedName.replace("{DATE}",
> currentDate);
>
> setAttachmentName(generatedName);
>
> }
>
>
>
> // Move content to an attachment.
>
> try {
>
> MimeBodyPart mimeBodyPart = new MimeBodyPart();
>
>
>
mimeBodyPart.setContent(inputMessage.getContent(),inputMessage.getConten
> tType());
>
> mimeBodyPart.setFileName(getAttachmentName());
>
> Multipart multipart = new MimeMultipart();
>
> multipart.addBodyPart(mimeBodyPart);
>
> inputMessage.setContent(multipart);
>
>
>
> } catch (IOException ioe) {
>
> log.error("IOException " + ioe.getMessage());
>
> throw new TransformerException(this, ioe);
>
> } catch (MessagingException me) {
>
> log.error("MessagingException " + me.getMessage());
>
> throw new TransformerException(this, me);
>
>
>
> }
>
> return inputMessage;
>
> }
>
>
>
> public String getAttachmentName() {
>
> return attachmentName;
>
> }
>
>
>
> public void setAttachmentName(String attachmentName) {
>
> this.attachmentName = attachmentName;
>
> }
>
> }
>
>
>
>
>
> I used it in my config file as follows:
>
>
>
> <transformer name="GGMailContentsToAttachment"
>
>
className="miraculum.mule.TfmMailContentsToAttachment"
>
> returnClass="javax.mail.Message">
>
> <properties>
>
> <property name="attachmentName"
> value="GA01-{DATE}.txt" />
>
> </properties>
>
> </transformer>
>
>
>
> Regards,
>
> Wayne Wundram
>
>
>
> ________________________________
>
> From: VinithGowda [mailto:
vinith.hr@...]
> Sent: Friday, July 04, 2008 7:16 AM
> To:
user@...
> Subject: [mule-user] Attach File to E-mail (SMTP)
>
>
>
> Hi All, I would like to attach a file to the mail sending through SMTP
> connector,which is the best way doing it. Thanks in Advance, Vinith
> Gowda.
>
> ________________________________
>
> View this message in context: Attach File to E-mail (SMTP)
>
<
http://www.nabble.com/Attach-File-to-E-mail-%28SMTP%29-tp18272975p18272> 975.html>
> Sent from the Mule - User mailing list archive
> <
http://www.nabble.com/Mule---User-f2727.html> at Nabble.com.
>
>
>
--
View this message in context:
http://www.nabble.com/Attach-File-to-E-mail-%28SMTP%29-tp18272975p18273851.html
Sent from the Mule - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email