Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Posts: 73
Registered: ‎12-30-2011
My Device: All devices

Append Custom message to cofigured email client Folder

Hi every one,

 

       I append a  custom message to INBOX folder programatically , but meesage is append into native Message folder not in my email client folder, please help me i want to show custom message in both folder.

 

public void addNewMessage(){	
		
		Session session = Session.waitForDefaultSession();  
		Store store = session.getStore();  
		Folder[] folders = store.list(Folder.INBOX);  
		Folder inbox = folders[0]; 
		Message newmsg = new Message();

		newmsg.setContent("farhan"); 
		Address addrs = new Address("m.farhan@dbydx.com","farhan");

		newmsg.setFrom(addrs);  
		newmsg.setStatus(Message.Status.RX_RECEIVED, Message.Status.RX_RECEIVED);  
		newmsg.setSentDate(new Date(System.currentTimeMillis()));  
		newmsg.setFlag(Message.Flag.REPLY_ALLOWED, true);  
		newmsg.setInbound(true);  
		newmsg.setSubject("Test");  

		inbox.appendMessage(newmsg); 
    }		

 

Thanks

Mohd Farhan
Regular Contributor
Posts: 73
Registered: ‎12-30-2011
My Device: All devices

Re: Append Custom message to cofigured email client Folder

If I append message like that, but still same problem

  public void appendMessage(Message message,String fname){
        ServiceBook sb = ServiceBook.getSB();
        ServiceRecord[] srs = sb.getRecords();

         for(int cnt = srs.length - 1; cnt >= 0; --cnt) {
                
              if( srs[cnt].getCid().equals( "CMIME" )) {
                   ServiceConfiguration sc = new ServiceConfiguration(srs[cnt]);
                   Store store = Session.getInstance(sc).getStore();
                   //Session.getInstance(sc).addViewListener(this);
                    
                   Folder[] folders = store.list();
                   for( int foldercnt = folders.length - 1; foldercnt >= 0; --foldercnt) {
                       Folder f = folders[foldercnt];
                       recurse(f,message,fname);
                    }    
               }
           } 
    }
    
  public void recurse(Folder f,Message msg,String foldername){
      try{
        System.out.println("Folder Name :"+ f.getFullName() +"  " + "Folder Type" + f.getType());
       if( f.getType() == Folder.INBOX){
          if(f.getFullName().equalsIgnoreCase(foldername)){
              f.appendMessage(msg); 
          }     
        }
        Folder[] farray = f.list();
        for (int fcnt = farray.length - 1; fcnt >= 0; --fcnt){
           recurse(farray[fcnt],msg,foldername);
        }
       }catch(Exception ex){ System.out.println("Message error."+ex.getMessage());} 
      } 

 

i call this method  to append message to specific folder but still same problem show only in Message Inbox folder not cofigured email folder.

Thanks

Mohd Farhan