Thanks for your reply. May be I did not explain my question clearly.

I am using JAMES to handle the emails forwarded from a Groupwise client. I am planning 
to use JAMES only to handle the forwarded emails from Group wise. once JAMES server 
receive the emails from Group wise, my thread process will open the JAMES INBOX folder 
and make a summary list from the mails in the inbox and notify the admin with the 
summar list and delete all the messages from the inbox. I prefer to use the standard 
JAVAMAIL API methods to connect and manipuate the messages in the JAMES server so I am 
not tied to JAMES. I am successfully able to  connect to the JAMES server and look at 
the messages. But I am having difficulties in creating a new folder where I want to 
copy the messages and delete the messages in inbox  after I notify the admin. 
Thanks

>>> [EMAIL PROTECTED] 04/05/04 11:30AM >>>
if you want to deal with bounced mail ...
you have to add your code in RemoteDelivery.java

somewhere along on failMessage()

jaggy
 

private boolean failMessage(MailImpl mail, MessagingException ex, boolean permanent) {
    StringWriter sout = new StringWriter();
    PrintWriter out = new PrintWriter(sout, true);
    if (permanent) {
      out.print("Permanent");
    } else {
      out.print("Temporary");
    }
    StringBuffer logBuffer =
            new StringBuffer(64)
            .append(" exception delivering mail (")
            .append(mail.getName())
            .append(": ");
    out.print(logBuffer.toString());
    ex.printStackTrace(out);
    log(sout.toString());
    if (!permanent) {
      if (!mail.getState().equals(Mail.ERROR)) {
        mail.setState(Mail.ERROR);
        mail.setErrorMessage("0");
        mail.setLastUpdated(new Date());
      }
      int retries = Integer.parseInt(mail.getErrorMessage());
      if (retries < maxRetries) {
        logBuffer =
                new StringBuffer(128)
                .append("Storing message ")
                .append(mail.getName())
                .append(" into outgoing after ")
                .append(retries)
                .append(" retries");
        log(logBuffer.toString());
        ++retries;
        mail.setErrorMessage(retries + "");
        mail.setLastUpdated(new Date());
        return false;
      } else {
        logBuffer =
                new StringBuffer(128)
                .append("Bouncing message ")
                .append(mail.getName())
                .append(" after ")
                .append(retries)
                .append(" retries");
        log(logBuffer.toString());
      }
    }
// any bounced related add-ons should be added here
// below this line is the sample code to log bouncemail in reply-to,recepient,subject 
format per line
    MimeMessage mm = null;
    String subj = null;
    String errorTo = null;
    try {
      mm = mail.getMessage();
      subj = mm.getSubject();
    }
    catch (MessagingException e) {
      System.out.println(e.getMessage());
    }
    for (Iterator i = mail.getRecipients().iterator(); i.hasNext();) {
      StringBuffer lbf = new StringBuffer(128)
              .append(mail.getSender())
              .append(",")
              .append(i.next())
              .append(",")
              .append(subj);
      Date mydate = new Date();
      SimpleDateFormat formatter;
      formatter = new SimpleDateFormat("MM-dd-yyyy");
      try {
        FileWriter daWriter = new FileWriter("C:/BOUNCEDMAIL/bounced_" + 
formatter.format(mydate).toString() + ".log", true);
        daWriter.write(lbf.toString() + "\r\n");
        daWriter.close();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
      out.println(i.next());
    }
    subj = null;
    errorTo = null;
    bounce(mail, ex);
    return true;
  }

-----Original Message-----
From: Alagan Sathianathan [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 05, 2004 12:16 PM
To: [EMAIL PROTECTED] 
Subject: James to manage the bounced emails


I am using James to hadnle the bounced emails. When ever there is a bounced mail  
from, it will be forwared to my James Server. I am running a thrad process to look at 
the bounced mails and forward the mails to some admin and delete the messages.

But I have problems in deleting the messages.Geting 
"javax.mail.MethodNotSupportedException: Expunge not supported
" . Here id the code:
//
public void process() {         
                try {
                        Message msgs[] = getMessages();
                        if( msgs != null){
                        log.info("Processing "+msgs.length+" Messages");
                        }
                        if (msgs != null)
                                for (int i = 0; i < msgs.length; i++) {
                                        if (!wasProcessed(msgs[i])) {
                                                msg[i].setFlag(Flags.Flag.DELETED, 
true);                                       }
                                }

                        
                        // Notify REPLYTO Address
                        // TODO to be implemented
                        // delete them from inbox  HAVING PROBELM HERE
                        folder.expunge();

                } catch (Exception e) {
                        // TODO: handle exception
                        log.warn("Exception thrown");
                }
        }
//


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to