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
New Developer
Posts: 108
Registered: ‎01-23-2012
My Device: torch,bold,curve,strom
My Carrier: Blackberry
Accepted Solution

Adding Listener Problem After sending The Mail

Hi All,

 I have to add listener after mail sent because i have to hit one service when the mail will sent.

 

Please Help!

 

Its Urgent..

 

 

Thanks! 

Thanks & Regards,
Kumar Shivam
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Adding Listener Problem After sending The Mail

Sorry Im not 100% clear what you are asking here.

 

Do you create an email and you want to know when it has been sent?

New Developer
Posts: 108
Registered: ‎01-23-2012
My Device: torch,bold,curve,strom
My Carrier: Blackberry

Re: Adding Listener Problem After sending The Mail

Hi peter,

 

No actually i am using folder listener but it is not working 

 

can you please suggest!

Thanks & Regards,
Kumar Shivam
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Adding Listener Problem After sending The Mail

Two questions:

 

1) What do you actually need to do?

Please describe your requirement

 

2) Which folder have you attached your Listener to?

Developer
Posts: 107
Registered: ‎05-26-2011
My Device: Torch
My Carrier: Mobilink

Re: Adding Listener Problem After sending The Mail

[ Edited ]

Use this code

Message m = new Message();
		
		long millis = System.currentTimeMillis();
		Date d = new Date(millis);

		m.setSentDate(d);
		
			Address a = null;
		try{	
					a = new Address(_dto.get_email(), _dto.get_fname() + " "
							+ _dto.get_lname());
					

				} catch (AddressException e) {
				
					e.printStackTrace();
				}
			}
		}
		

		try {

			m.addRecipients(
					net.rim.blackberry.api.mail.Message.RecipientType.TO,
					addresses);
		} catch (MessagingException e) {

			e.printStackTrace();
		}
		try {
			m.setContent("\n\n\nbody");

			m.addMessageListener(new MessageListener() {

				public void changed(MessageEvent e) {
/////// here you can check the messageevent instance and check the code //of the event

if (e.getMessage().getStatus() == Message.Status.TX_DELIVERED
								|| e.getMessage().getStatus() == Message.Status.TX_SENT) {
							//Message Sent

						} else if (e.getMessage().getStatus() == Message.Status.TX_ERROR
								|| e.getMessage().getStatus() == Message.Status.TX_GENERAL_FAILURE) {
							//Message failed

						} else
//Pending

}

} catch (MessagingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,
				new MessageArguments(m));

 

 

New Developer
Posts: 108
Registered: ‎01-23-2012
My Device: torch,bold,curve,strom
My Carrier: Blackberry

Re: Adding Listener Problem After sending The Mail

Thanks madiha

 

Thanks for your reply . It works fine ! 

 

Thanks for your valuable suggestion!

 

 

Thanks & Regards,
Kumar Shivam
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Adding Listener Problem After sending The Mail

Can you mark this as solved then?  Thanks