Rotina em JAVA para enviar email com anexo

amigos,

preciso criar uma rotina em JAVA para enviar um email para o cliente com um arquivo XML anexo

alguém pode me ajudar

Dario

Qual é sua dúvida ? como enviar email com anexo ?

http://www.java2s.com/Code/Java/Email/HowtousetheFileDataSourcetosendafileviamail.htm

Segue exemplo

import java.io.File;
import java.util.Properties;
import javax.activation.CommandMap;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.activation.MailcapCommandMap;
import javax.mail.Authenticator;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;



public class SendMail {

    String server = "seuservidor"
    private String host = server; /* endereço do servidor smtp */


    public class SMTPAuthenticator extends Authenticator {

        @Override
        public PasswordAuthentication getPasswordAuthentication() {
            String user ="seuusuario"
            String pwd = "senhadousuario";
            String username = "seunome";
            String password = "seupwd";
            return new PasswordAuthentication(username, password);
        }
    }


    public void EnviarEmailPara(String para, String assunto, String mensagem) throws Exception {
        Properties mailProps = System.getProperties();
        mailProps.put("mail.smtp.host", this.host);
        String fileAttachment = "";
        Authenticator auth = new SMTPAuthenticator();
        Session session = Session.getDefaultInstance(mailProps, auth);

        mailProps.put("mail.smtp.auth", "true");
        mailProps.put("mail.debug", "true");
        mailProps.put("mail.smtp.debug", "true");
        mailProps.put("mail.mime.charset", "ISO-8859-1");
        mailProps.put("mail.smtp.port", "25");
        
        MailcapCommandMap mc = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
        mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
        mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
        mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
        mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
        mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
        CommandMap.setDefaultCommandMap(mc);

        // Definir mensagem
        MimeMessage message = new MimeMessage(session);
        String from = TmpSend.getInstance().getuser();

        message.setFrom(new InternetAddress(from));
        message.addRecipient(Message.RecipientType.TO,new InternetAddress(para));
        message.setSubject(assunto);
        //JOptionPane.showMessageDialog(null,message.getFrom()[0].toString() + " " + message.getAllRecipients()[0].toString());
        // Criar parte da mensagem
        MimeBodyPart messageBodyPart = new MimeBodyPart();

        // Texto da mensagem
        messageBodyPart.setText(mensagem);

        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart);

        BodyPart bodyPart = new MimeBodyPart();
        FileDataSource fileDataSource = new FileDataSource(new File("seuarquivo.txt"));
            bodyPart.setDataHandler(new DataHandler(fileDataSource));
            bodyPart.setFileName("seuarquivo.txt");
            message.setFileName("seuarquivo.txt");
   

        }
        multipart.addBodyPart(bodyPart);
        // Enviar parte da mensagem
        message.setContent(multipart);

        //message.setContent(mensagem.toString());

        Transport.send(message);

        
        
    }