james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sijarahmed <sijar.ah...@gmail.com>
Subject Saving email attachments not working from gmail,yahoomail / but working with Test-Program
Date Thu, 12 Mar 2009 03:53:21 GMT

Hi everybody !!

         This is my 2nd post this is forum & I'm back with much interesting
Problem.
         
         I'm using JAMES inside my app-Server JBoss, to fetch mails with
attachment from gmail,yahoo etc.
         This is what I have been using Phoenix version 4.0.3, James 2.1.3,
JMXLauncher.jar and Jdk 1.4

         Till now I'm successfully able to receive mails from gmail,yahoo.       
         As my fetchmail is working to get these emails at regUser@myApp.com
.
         Now I have written a custom mailet called HasValidEmail in order to
process the email
         attachments and save it in a specific path in directory.

         ////////////////////////////// config.xml
///////////////////////////////////////////////////
         <!-- CUSTOM MAILET STARTS -->  
         <mailet match="All" class="HasValidEmail">
            <pattern>.*\.xls</pattern>
           <directory> D:/myapp/document/</directory>
        </mailet>
        <!-- CUSTOM MATCHER ENDS -->  
       
///////////////////////////////////////////////////////////////////////////////////////////////


         Everything seems to work fine when I test the mailet, with the
following code.
         That means I recieve the mail and attachment from sender
abcd@gmail.com
         who sends to regUser@myApp.com and then my mailet runs I am able to
         save it.

//////////////////////// TEST CODE TO SEND MSG & ATTACHMENT
//////////////////////////

        public javax.mail.internet.MimeMessage sendAttachment() throws
Exception {
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress("abcd@gmail.com"));
        message.addRecipient(Message.RecipientType.TO,new
InternetAddress("regUser@myApp.com"));
        message.setSubject("1101;insurance;today");        

        BodyPart messageBodyPart = new MimeBodyPart();        
        messageBodyPart.setText("Hi There !! this code works");        
        Multipart multipart = new MimeMultipart();
        multipart.addBodyPart(messageBodyPart);        
        // Part two is attachment
        messageBodyPart = new MimeBodyPart();
        DataSource source = new FileDataSource("d:/Report.xls");
//Hard-Coded
        messageBodyPart.setDataHandler(new DataHandler(source));
        messageBodyPart.setFileName("Report.xls");
        multipart.addBodyPart(messageBodyPart);        
        // Put parts in message
        message.setContent(multipart);        
        // Send the message
        Transport.send(message);        
        //set msg to Mail
        //mail.setMessage(message);
        return message;
    }
///////////////////////////////////////////////////////////////////////////////////////////////

 
  ************************ PROBLEM **************************************
   But when the user actually sends the above mail with same attachment from
abcd@gmail.com
   to regUser@myApp.com and then my mailet doesn't seem to run, although I
am able to get
   the message but attachment is not getting saved as it should be.

    Can anybody help in tracing the cause and guide me through so that I
nail this problem.
    To be fair it has become a pain in the a**.

    Any relevant suggestion would be great help...

 Thanks !!

   "When the power of love overcomes the love of power the world will know
peace."
    --- Jimi Hendrix

-- 
View this message in context: http://www.nabble.com/Saving-email-attachments-not-working-from-gmail%2Cyahoomail---but-working-with-Test-Program-tp22469453p22469453.html
Sent from the James - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message